Closed newhouse closed 3 years ago
Looks good!
Let's good with the following approach:
const result = fromIntrospectionQuery(introspection, { nullableArrayValues: true });
Note: should we have a flag for all nullable types? wrapping all nullable types in a anyOf
Consider the following GraphQL SDL:
The Field
bar
on the TypeFoo
is of typeString
...which can be described in English as:(All of this is opposed to if the type of
bar
wasString!
, which would mean it should always have aString
value)Currently, the above SDL will result in a JSON Schema from this library that looks like the following:
But, I believe in JSON Schema that actually says something more like:
Perhaps this is fine the way it is, and the fact that
required: []
is an empty array signals thatbar
may benull
/empty/undefined?But if not, perhaps the output should be more like this:
But let's consider another SDL:
In English, this is something like:
The JSON Schema this library outputs in this case looks like so:
Which I think says that the items in the
bar
array can NOT benull
...which does not play nice with the GraphQL Schema type definition.I think that JSON Schema standards would say it should look something like this:
Anyways...I think you see where I'm going with all this, and would like to hear your thoughts...