You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If applicable, what version of Node.js are you using?
22.8
Amplify CLI Version
12.11.1
What operating system are you using?
Mac
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
N/A
Describe the bug
When including multiple custom queries in split graphql schema files (following the guide here) the auth directives do not carry over into the generated schema.graphql file. This only occurs for the queries defined under the extend type Query { ... } syntax. The queries defined in type Query { ... } behave as expected.
Expected behavior
I expect auth directives like @aws_iam @aws_cognito_user_pools to appear for all custom-queries configured with auth, regardless if they are declared under the base type or the extended type.
Reproduction steps
Create two .graphql files under the schema directory in a project with a graphql api.
In one file, declare a custom query using type Query { ... }
Add an @auth rule like @auth(rules: [{ allow: private, provider: userPools }])
In the other schema file, declare a custom query using extend type Query { ... }
Add an @auth rule like above.
Run amplify build
Observe in compiled schema.graphql file that the auth directives are missing from the second custom query:
matt-at-allera
changed the title
Extended 'Query' type does not carry over directives
Extended 'Query' type does not carry over auth directives
Nov 19, 2024
Hey @matt-at-allera👋, thanks for raising this issue.we are working on reproducing the issue. Could you please run below command and send us the project identifier. amplify diagnose --send-report.
please refer here.
Hey @matt-at-allera, I was able to reproduce the issue based on the description provided. Therefore, I am marking this as a bug for the team to evaluate further.
schema1:
type Todo @model @auth(rules: [{ allow: private, provider: userPools }]) {
id: ID!
name: String!
description: String
}
type Query {
myCustomQuery(args: String): String
@auth(rules: [{ allow: private, provider: userPools }]) # your custom queries here
}
schema2:
type Todo2 @model @auth(rules: [{ allow: private, provider: userPools }]) {
id: ID!
name: String!
description: String
}
extend type Query {
myCustomQuery2(args: String): String
@auth(rules: [{ allow: private, provider: userPools }]) # your custom queries here
}
The generated schema is missing the auth configuration for myCustomQuery2.
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
22.8
Amplify CLI Version
12.11.1
What operating system are you using?
Mac
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
N/A
Describe the bug
When including multiple custom queries in split graphql schema files (following the guide here) the auth directives do not carry over into the generated
schema.graphql
file. This only occurs for the queries defined under theextend type Query { ... }
syntax. The queries defined intype Query { ... }
behave as expected.Expected behavior
I expect auth directives like
@aws_iam @aws_cognito_user_pools
to appear for all custom-queries configured with auth, regardless if they are declared under the base type or the extended type.Reproduction steps
schema
directory in a project with a graphql api.type Query { ... }
@auth(rules: [{ allow: private, provider: userPools }])
extend type Query { ... }
amplify build
schema.graphql
file that the auth directives are missing from the second custom query:Project Identifier
No response
Log output
Additional information
No response
Before submitting, please confirm:
The text was updated successfully, but these errors were encountered: