graphql-to-json-schema
graphql-to-json-schema copied to clipboard
"Nullable" fields have wrong type
The difference between a "nullable" and a non-null field is currently handled using the "required" property on the JSON schema object. This is only partly correct, as a nullable field can either be not specified (it is not required) or it can be assigned null
.
The required behavior should stay, but if the field is not declared as non-null, the fields should be as follows:
Lists
{
"type": ["array", "null"]
}
Types
{
"type":{
"oneOf":[
{
// or whatever the actual type is
"type":"string"
},
{
"type":"null"
}
]
}
}
Have you tried setting the nullableArrayItems
option to true
as described in the README?
Also, it would help if:
- You provided a small sample SDL that will replicate what you're talking about
- Provide the output you're seeing
- Provide the output you're expecting (you've don that here, thanks!)