Skip to content

Instantly share code, notes, and snippets.

@vladfaust
Created May 4, 2017 22:11
Show Gist options
  • Save vladfaust/8087eb07d6c57be5bced53a4d2c1dc78 to your computer and use it in GitHub Desktop.
Save vladfaust/8087eb07d6c57be5bced53a4d2c1dc78 to your computer and use it in GitHub Desktop.
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