Skip to content
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

Declaring schema directive on extended type does not populate astNode.directive property #1296

Closed
simon-bigsofa opened this issue Mar 11, 2020 · 4 comments

Comments

@simon-bigsofa
Copy link

simon-bigsofa commented Mar 11, 2020

Declared a custom @auth directive on OBJECT:
directive @auth on OBJECT

The directive extends SchemaDirectiveVisitor and implements visitObject

When the directive is applied to the original type it works correctly and the type requires authorisation.

type Stream @auth {
  name: String!
}

When the directive is applied to an extended type (and not the original type definition) it is completely ignored.

  extend type Stream @auth {
    uid: String!
  }

When applied to the extended type the astNode.directives property of the Stream type is empty.

I couldn't see anything in the docs or the spec which suggests that OBJECT level directives can not be applied to extended types. Any ideas?

@yaacovCR
Copy link
Collaborator

Caused by checking only astNode rather than also all extensionASTNodes at https://github.com/apollographql/graphql-tools/blob/master/src/schemaVisitor.ts#L546

Fixed in graphql-tools-fork v8.9.5

@simon-bigsofa
Copy link
Author

That's fantastic @yaacovCR - Indeed that has fixed the issue. Thank you!

@TimSusa
Copy link

TimSusa commented Mar 21, 2020

Why just not taking over graphql-tools-fork fixes to graphql-tools? Really hard for me to understand, just to say its deprecated. Seems to me, like a sad story.

@yaacovCR
Copy link
Collaborator

Folded into #1306, fixed by #1307

@yaacovCR yaacovCR mentioned this issue Mar 29, 2020
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants