Skip to content

Instantly share code, notes, and snippets.

@thoth-ky
Last active March 18, 2019 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thoth-ky/9887a53a56ba058b424f8824b5eb3570 to your computer and use it in GitHub Desktop.
Save thoth-ky/9887a53a56ba058b424f8824b5eb3570 to your computer and use it in GitHub Desktop.
app/graphql/types/query_type.rb
module Types
class QueryType < Types::BaseObject
field :all_books, [BookType], null: true, description: "Returns a list of all Books"
field :book, BookType, null: true do
description "Returns book given an ID"
argument :id, ID, required: true
end
def all_books
Book.all
end
def book(id:)
Book.find_by(id: id)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment