Created
February 5, 2018 15:35
-
-
Save adamjleonard/48444521c9ef7552ebedc625143ad0cc to your computer and use it in GitHub Desktop.
query_type.rb
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
Types::QueryType = GraphQL::ObjectType.define do | |
name “Query” | |
# Add root-level fields here. | |
# They will be entry points for queries on your schema. | |
field :allMovies do | |
type types[Types::MovieType] | |
description “A list of all the movies” | |
resolve -> (obj, args, ctx) { | |
Movie.all | |
} | |
end | |
field :movie do | |
type Types::MovieType | |
description “Return a movie” | |
argument :id, !types.ID | |
resolve -> (obj, args, ctx) { Movie.find(args[:id]) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment