Skip to content

Instantly share code, notes, and snippets.

@goodpic
Created April 24, 2018 17:22
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 goodpic/95ca2b760b47c57b388edc7ea4346d3e to your computer and use it in GitHub Desktop.
Save goodpic/95ca2b760b47c57b388edc7ea4346d3e to your computer and use it in GitHub Desktop.
module Types
class QueryType < GraphQL::Schema::Object
# Add root-level fields here.
# They will be entry points for queries on your schema.
# queries are represented as fields, use [Types::XXX] for the list
field :product, Types::ProductType,
null: true,
resolve: ->(_obj, args, _ctx) {
Product.find(args.id)
} do
argument :id, String, required: true
argument :days, Int, required: false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment