6

I am using the [graphql][1] gem to build out a GraphQL API.

When defining inputs for example --

Inputs::BranchInput = GraphQL::InputObjectType.define do
  name 'BranchInput'

  argument :scope,                      types.String
end

The argument scope is actually an enum field that will accept either small or big. How can I define this in the input that this argument will only accept these two values? Is it possible to show this in the docs as well when they are generated so that the UI developers are also clear on this?

When using Grape to generate REST APIs, I would generally use to values parameter to define something like this.

Michael Victor
  • 861
  • 2
  • 18
  • 42
  • 2
    This is a late answer, but I imagine you'd want something like an Enum, it's what we're using for similar case. https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/enum_type.rb – brainbag Jun 28 '18 at 21:05

0 Answers0