How to define JSON custom scalar type in graphql which can be nullable?

217 views Asked by At

https://github.com/graphql/graphql-js/issues/3532#issuecomment-1125126566

serialize() can not return null, so I'm getting GRAPHQL error {"errors":[{"message":"Expected JsonType.serialize(\"null\") to return non-nullable value, returned: null" error where JsonType is my customized scalar.

I know graphql-scalars package includes a JSON scalar type, but I'm using my custom one where serialize() can parse from a Buffer or string. It used to work but in graphql 16 I can not return null in serialize() after this change.

I'm wondering what's the recommended way to handle it in this case, if I use a wrapper all schema would need to change due to the nesting.

0

There are 0 answers