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
GraphQL directive ordering not respected #6176
Comments
This issue is important when chaining functions inside a pipeline resolver with directives, like I have done here: |
@half2me this is by design as we don't want to change the behavior of the transformer based on the order in which the transformer is executed based on the input document. For instance lets say if some one defines a schema like below type Post
@auth(rules: [{ allow: owner }])
@key(name: "postByTitle", fields: ["title"])
@model {
id: ID!
title: String!
content: String!
}
the transformer wont be in a position to write the We have a Transformer redesign in progress which is hidden behind Feature Flag |
@yuth thanks for clarifying this. I did think this was done by design, but I think it could be very useful to consider the order of the directives when applying transformers, as it allows for more powerful manipulation. With the current design, you have no way of controlling the order. Having a requirement of defining This feature flag sounds nice, I'll give it a try. Is there an up-to-date list of all the feature flags available? |
All the feature flags should be documented here, but unfortunately its not up to date. More upto date list can be found here in the code amplify-cli/packages/amplify-cli-core/src/feature-flags/featureFlags.ts Lines 501 to 563 in d6c44cc
|
We do have an RFC open for this at the moment. Closing in favor of the RFC. The only available directives would be |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Describe the bug
The order of directives on a graphql schema is not always respected.
Amplify CLI Version
4.39.0
To Reproduce
Take the following schema for example:
In this case, the order the directives are applied is:
@another_directive
@my_directive
If we swap the directives, like so:
The order does not get reversed as expected. The ordering instead depends on the order that the transformers were defined in.
However using the same directive twice, say with different arguments, the order is properly kept.
Results in:
@my_directive(option: "A")
@my_directive(option: "B")
And reversing them like so:
Produces:
@my_directive(option: "B")
@my_directive(option: "A")
Expected behavior
Order of directives should be respected.
Desktop (please complete the following information):
Additional context
Tested by running
amplify mock
The directives were custom transformers that I wrote, and they are always executed in the order that they are added to the
transform.conf.json
file, instead of the order of the directives.The text was updated successfully, but these errors were encountered: