Created
May 4, 2017 22:11
-
-
Save vladfaust/8087eb07d6c57be5bced53a4d2c1dc78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module API | |
module Queries | |
module User | |
Fragment = Client.new.parse <<- 'GRAPHQL' # There is no space in the code, just for Gist | |
fragment on User { | |
id | |
status | |
} | |
GRAPHQL | |
end | |
end | |
end | |
module API | |
module Queries | |
module User | |
Find = Client.new.parse <<- 'GRAPHQL' # There is no space in the code, just for Gist | |
query($id: Int) { | |
user: user(id: $id) { | |
...API::Queries::User::Fragment | |
} | |
} | |
GRAPHQL | |
end | |
end | |
end | |
r = exec_query(API::Queries::User::Find, id: 42) | |
r.data.user.id | |
#=> GraphQL::Client::QueryResult::ImplicitlyFetchedFieldError: implicitly fetched field `id' on User type. https://git.io/v1yGL | |
#=> user: user(id: $id, telegramId: $telegram_id) { | |
#=> ...API__Queries__User__Fragment | |
#=> + id | |
#=> } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment