Is your feature request related to a problem? Please describe.
My schema has a jsonb scalar fileld type. However, the TypeScript codgen plugin simply resolves this to an any TypeScript type. I am looking for a way to provide a custom override type for that field, so that I can get access the JSon contents of that field in a stongly typed way.
Describe the solution you'd like
I would like to simple mechanism to provide a custom type for a given field, so that the code-generation uses the custom priovided type instead of the original schema provided type
Describe alternatives you've considered
Additional context
I am using an Hasura API, with typescript and typescript-react-apollo plugins
@ahrnee just overriding the field doesn't work?
redeclare it in a .graphql file and add it to your schema:, i think it should override the field type.
@dotansimha - thanks for your response, but that doesn't seem to work in my case. I get the following error:
Unable to merge GraphQL type "MyEntity": Field "myjsonbfield" already defined with a different type.
Declared as "MyCustomFieldType", but you tried to override with "jsonb"
Some Futher Details:
Sidenotes
Same problem here.
We generate types from Datocms GraphQL API.
Most of enums are just Scalars['String'].
We really need to override for some fields and we can not change the source API.
We tried to define a local schema but we have the same Error
Unable to merge GraphQL type "TitleRecord": Field "variant" already defined with a different type. Declared as "Variant", but you tried to override with "String"
Error: Unable to merge GraphQL type "TitleRecord": Field "variant" already defined with a different type. Declared as "Variant", but you tried to override with "String"
It would be very nice to allow merge if needed
I think the best way to do that is to use a custom schema loader, then you can manipulate your schema in any way you wish to. (for example, using graphql-compose to change the schema).
Closing.
Most helpful comment
@dotansimha - thanks for your response, but that doesn't seem to work in my case. I get the following error:
Some Futher Details:
Sidenotes