How best to make the codegen understand a custom directive? #5676
-
Let me start by expressing my gratitude for this set of awesome tools! I was especially blown away by "typescript-react-apollo" with its custom hooks. Internally, we have a directive called I'd love to enable the generated types to type a field with this directive as required correctly. But I am not sure where to start for this behavior. Could I get a pointer on where to begin? For reference, here is the definition of the directive:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
I can recommend you to add a transformation layer that would change the schema according to your needs, based on the spec. So |
Beta Was this translation helpful? Give feedback.
-
@aprilrd, ever found a way to modify the typing based on custom directives? I'm personally looking for a way to make an |
Beta Was this translation helpful? Give feedback.
I can recommend you to add a transformation layer that would change the schema according to your needs, based on the spec. So
@nonNull
can change a field to be non-nullable. This can be done with a custom schema loader: https://graphql-code-generator.com/docs/getting-started/schema-field#custom-schema-loader