Skip to content

Instantly share code, notes, and snippets.

@adamjleonard
Created February 5, 2018 15:35
Show Gist options
  • Save adamjleonard/48444521c9ef7552ebedc625143ad0cc to your computer and use it in GitHub Desktop.
Save adamjleonard/48444521c9ef7552ebedc625143ad0cc to your computer and use it in GitHub Desktop.
query_type.rb
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