Last active
March 18, 2019 07:30
-
-
Save thoth-ky/9887a53a56ba058b424f8824b5eb3570 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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