-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AppSync reject directive definition saying "Directive definitions are not supported." #25
Comments
As you mentioned you are seeing this issue because AppSync does add these directives definitions on top of your schema as part of AppSync core implementations. We decided not to add support to AppSync directives into this library because this is an open source solution and should NOT be limited to AppSync. |
Why not just update the tool to be able to ignore directives and scalar types? I'm not sure how useful this tool would be in other environments since most alternatives (Hasura, Apollo, etc) support schema stitching or federation, and I'd imagine people are arriving here because of the failure of AWS to handle this. Also, this workaround is saddening because not checking in that file means every member of the team needs to remember to add it to their source. It creates a convention that is hard to enforce for large teams or for multiple product teams working in the same repository. |
I have the same question. Right now I'm unable to use this with AppSync, because it either fails validation, or if I add in the custom types, it gets merged into the final output, and AppSync just rejects it. |
An ugly hack I've had to do is write a quick python script to strip the AppSync scalars and directives I've had to include. import sys
schema_file = sys.argv[1]
aws_types_file = sys.argv[2]
with open(aws_types_file, 'r') as f:
blacklist = list(filter(None, f.read().splitlines()))
with open(schema_file, 'r') as f:
print('\n'.join(filter(
lambda l: l not in blacklist,
filter(None, f.read().splitlines())
))) I include all the AppSync scalars and directives in a graphql file, so the tool doesn't complain about missing types and whatnot, plus you get all the validation benefits. The only problem is, its now included in the output, which AppSync doesn't like, so I run this little script to remove it. |
There is an option
|
I have found that the following repository will work when you need appsync directives. |
Using AWS CDK I'm able to get the directives to upload to AppSync successfully by adding the I have a "root.graphql" file where I define all of the base types for my API and just put the auth directives and scalars that I need in it. Here's an example: # define all base types so when other files extend them you don't get errors
directive @aws_oidc on FIELD_DEFINITION | OBJECT
directive @aws_api_key on FIELD_DEFINITION | OBJECT
scalar AWSDateTime
scalar AWSDate
scalar AWSURL
scalar AWSEmail
type Query
@aws_oidc @aws_api_key
type Mutation
@aws_oidc
|
in my schema I have subscription defined using @aws_subscribe
If I don't define following when I merge two schema file:
directive @aws_subscribe(mutations: [String!]!) on FIELD_DEFINITION
it will throw error saying "Error(1): Unknown directive "aws_subscribe""
If add the directive definition, when I upload to AppSync, it got rejected saying "Directive definitions are not supported."
How would I be able to merge the schema and use it for AppSync at the same time?
The text was updated successfully, but these errors were encountered: