graphql-to-json-schema icon indicating copy to clipboard operation
graphql-to-json-schema copied to clipboard

ID scalar is wrongfully declared with "type": "object"

Open tobias-tengler opened this issue 2 years ago • 2 comments

According to the specification the ID scalar can be "integer" or "string" when used as an input and only "string" when used as an output: https://spec.graphql.org/June2018/#sec-ID

Currently it's represented as "type": "object" in the JSON schema which seems wrong. In my opinion it should be "type": ["string", "integer"] Kind of hard to decide which is more appropriate, since the possible values change depending on the usage of the scalar as either input or output. However ["string", "integer"] seems a lot closer to the specification than "object".

tobias-tengler avatar Aug 07 '21 11:08 tobias-tengler

Can you please:

  1. Provided a small sample SDL that will replicate what you're talking about
  2. Provide the output you're seeing from using that SDL
  3. Provide the output you're expecting

newhouse avatar Sep 17 '21 15:09 newhouse

@newhouse like for nullable array, we could have an option like IdTypeMapping: 'string' | 'integer' = 'string' to specify which type should ID resolve to.

wdyt?

charlypoly avatar Sep 17 '21 21:09 charlypoly