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 3 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

Hi, is there an ETA for this? could this be fixed? also i'm trying to fix it now by reading code

yairyairyair avatar Jan 29 '23 15:01 yairyairyair

i think this line should be 'string' instead of 'object', am i correct? https://github.com/charlypoly/graphql-to-json-schema/blob/4e809f8b4d595eb22779d329c65cbfd050357b52/lib/reducer.ts#L207

yairyairyair avatar Jan 29 '23 16:01 yairyairyair

working on this.

newhouse avatar Jan 30 '23 01:01 newhouse

@yairyairyair @tobias-tengler This is done and released in [email protected]

newhouse avatar Feb 02 '23 17:02 newhouse