Better support for GraphQL directives
See original GitHub issueContinue the discussion from here: https://github.com/dotansimha/graphql-code-generator/pull/561
The idea is to have better support for directives such as @skip
, @include
, and other custom directives that become common such as @client
.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:14 (5 by maintainers)
Top Results From Across the Web
Directives - Apollo GraphQL Docs
A directive decorates part of a GraphQL schema or operation with additional configuration. Tools like Apollo Server (and Apollo Client) can read a...
Read more >GraphQL directives are underrated - LogRocket Blog
Some GraphQL servers have better support for directives than others. ... However, I believe directives are a better fit.
Read more >Exploring GraphQL Directives in the Wild | StepZen blog
These directives make GraphQL support incremental delivery of data. They enable the clients to tell the GraphQL server what is the relative ...
Read more >How to use GraphQL Directives efficiently - Level Up Coding
GraphQL Directives are powerful tools but they are underrated. Let's know more about what are GraphQL Directives? when should you use GraphQL Directives?...
Read more >GraphQL directives you should know about - Hasura
Perhaps a more common use-case among API designers would be implementing a directive like this @rest directive. Its arguments take a REST ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i am also having an issue because i am using AWS AppSync, i got a directive
@aws_subscribe
in my schema. the cli returns:error: Directive aws_subscribe: Couldn't find type aws_subscribe in any of the schemas.
a nice way to handle custom/popular directives would be awesome.
Yes, my
aws-enhancements.graphql
contains my aws specific schema enhancements so the codegen knows about e.g. the@aws_subscribe
directive. I basically followed this documentation and also checked out the already provided templates.Since I am using this codegen for my typescript backend only I do not need the
@connection
directive or any other query types. (I am planning to also introduce this codegen in the frontend in the future. Though for now, I am only generating the model types for my TS backend.) Myaws-enhancements.graphql
is very minimal for now:The way I came to this solution was by checking out the mongodb template directives. This way the codegen knows about the directive and it’s valid. I bet you can do the same with your @connection directive.
When providing a custom schema in your codegen project config I think you don’t even need to write your custom templates too. Though if you want to, I also found the types available in the handlebars templates: https://github.com/dotansimha/graphql-code-generator/blob/master/packages/graphql-codegen-core/src/types.ts With these typedefs and the already provided template source code it was very easy to create my custom templates the way I need it in my project.
So imo the
graphql-code-generator
does not require a better support for 3rd party directives since actually, it’s already easy to integrate them. Maybe the documentation about it should be improved. So users, who actually need custom schema enhancements get an easy manual to do so.