Unknown directive "aws_subscribe". invalid-graphql-schema
See original GitHub issueLooks like v0.2.0
is breaking with custom directives
Unknown directive “aws_subscribe”. invalid-graphql-schema
I can’t see in the documentation how to customize invalid-graphql-schema
rule to enable custom directives like @aws_subscribe
for AWS AppSync. Is there a way?
type Subscription {
addedPost: Post
@aws_subscribe(mutations: ["addPost"])
updatedPost: Post
@aws_subscribe(mutations: ["updatePost"])
deletedPost: Post
@aws_subscribe(mutations: ["deletePost"])
}
Reference: https://docs.aws.amazon.com/appsync/latest/devguide/real-time-data.html
PS: By the way thank you for you tool 👍 and I suggest you to use git tags and GitHub releases every time you release a new version https://github.com/cjoudrey/graphql-schema-linter/releases
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
AWS Amplify GraphQL Unknown Directive in Android Studio
I have been experimenting with AWS Amplify to generate a GraphQL API and backend. I can create a working backend using the guided...
Read more >graphql-schemax - NPM Package Overview - Socket.dev
Where schema.addIgnoreRules(['Unknown directive']) can be read as follow: Ignore GraphQL errors whose message starts with 'Unknown directive'.
Read more >API (GraphQL) - Client code generation - AWS Amplify Docs
The amplify codegen statements command generates GraphQL statements(queries, mutation and subscription) based on your GraphQL schema.
Read more >Authorization and authentication - AWS AppSync
For this schema, assume that AWS_IAM is the default authorization type on the AWS AppSync GraphQL API. This means that fields that don't...
Read more >Server-side caching - Apollo GraphQL Docs
You can define field-level cache hints statically in your schema definition ... Apollo Server throws an Unknown directive "@cacheControl" error on startup.
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 Free
Top 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
Agreed, I kinda want to stick with
graphql-schema-linter linter/aws_appsync.graphql schema.graphql
for now and see how it plays out.Currently the workaround would be to provide the AWS AppSync type definitions when linting your schema. These definitions can live in a separate file than your schema.
Create a file named
aws_appsync.graphql
, for example:Then when running
graphql-schema-linter
specify this file, for example:One problem you might run into is the linter will complain about unused types, for example:
I would comment out the types you don’t use. This isn’t great, but it works for now.
Hi @yvele, thanks for the feedback and opening this issue. 😄
This is an interesting issue. Have you considered including a directive definition at the top of your schema or in a separate file? Something like this:
By doing this, the linter error would go away and your schema would be complete which might make it easier for someone new to add a
@aws_subscribe
elsewhere.In an ideal world, it would be great if AWS AppSync provided an SDL file with all the custom directives it supports, that way you could either extend the schema with it or simply pass both files to
graphql-schema-linter
.An alternative solution would be to customize
invalid-graphql-schema
as you suggested, but I’m hesitant because it encourages people to write incomplete schemas.Any further thoughts?
👍 That’s a great point. I completely forgot to do this since the beginning. 😢I’ll see if I can retroactively create them based on commit data. In the meantime, CHANGELOG.md might be helpful.
Edit: I’ve started re-adding them retroactively. Thanks for calling this out. 😄