I would like to override a the jsonb type for a speficic field in a graphql schema produced by Hasura and run through graphql-code-generator.
I have a customList
field of type jsonb. Ths is used to contain an array of json objects. When using graphql-code-generator with the TypeScript plugin, the generated type resolves to any
. I am trying to figure out how to override this with a custom Type for that specific field only.
The below snippets show the relevant section of graphql schema, and the targetted graphql type overrides. So far, everything I have tried results in codegen errors
GraphQl Schema
//schema.json
...
{
"kind": "OBJECT",
"name": “MyEntity”,
"description": "columns and relationships of MyEntity",
"fields": [
...
{
"name": "customList",
"description": "",
"args": [
{
"name": "path",
"description": "JSON select path",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "SCALAR",
"name": "jsonb",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
}
}
Targetted Override Types
//clientTypes.graphql
type ListItem {
itemId: string!
}
extend type MyEntity {
ccards: [ListItem!]
}
Thanks for any help!
Unable to merge GraphQL type "MyEntity": Field "customField" already defined with a different type. Declared as "MyCustomFieldType", but you tried to override with "jsonb"
(also mentioned here github.com/dotansimha/graphql-code-generator/issues/3051). How did you solve that? Is there a flag to "ignore" that error and force it? Thanks for your help. – Szechwan