-
-
Notifications
You must be signed in to change notification settings - Fork 822
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
getting directives from extensions does not follow gatesby convention as documented #2534
Comments
Thanks for raising this issue. You are completely correct that we are not following the gatsby convention and that the ability to order repeatable directives around other directives is lost. I agree with you that option 1 seems best way to address. A pr would be very welcome. |
Based on your careful wording above, I assume you are already aware of this, but for context of any other readers: This issue is not as bad as it might appear, and only affects repeatable directives. The current implementation can maintain order of non-repeating directives due to js respecting insertion order when iterating. I don't know when I'll have time, but I could probably take a stab at a PR. I can see a few different ways to implement this:
Having getDirective (or a new similar method) that always returns a consistent format (gatsby format) would be my preferred experience as a user. Having to always account for multiple formats in any usage would be a bit of a pain. This is also potentially the hardest sell, because its a breaking change, and any existing consumers of that method would need to update. Any thoughts on the best way to implement this? |
see #2534 BREAKING CHANGE: getDirectives now always return an array of DirectiveAnnotation objects New function getDirective returns an array of args records for each use of the directive, Note: this is true even when the directive is non-repeatable.
Available in the latest version! |
In a few places throughout the docs, it is indicated that directives can be read from extensions following conventions used by gatsby, layed out in this comment: graphql/graphql-js#1343.
This comment suggests a specific format for how directives should be formatted in extensions. It looks like the format actually expected by the SchemaDirectiveVisitor (and the return type of getDirectives) is different than this format.
The gatsby format suggests directives be an array like:
but instead the expected format is:
This format loses information about the order of directives.
eg. there is no way to tell the difference between:
and
Suggested solutions in order of my own preference:
The text was updated successfully, but these errors were encountered: