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

Extended 'Query' type does not carry over auth directives #3036

Open
2 tasks done
matt-at-allera opened this issue Nov 19, 2024 · 2 comments
Open
2 tasks done

Extended 'Query' type does not carry over auth directives #3036

matt-at-allera opened this issue Nov 19, 2024 · 2 comments
Assignees
Labels
api-graphql bug Something isn't working pending-community-response Issue is pending a response from the author or community.

Comments

@matt-at-allera
Copy link

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 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

  1. Create two .graphql files under the schema directory in a project with a graphql api.
  2. In one file, declare a custom query using type Query { ... }
  3. Add an @auth rule like @auth(rules: [{ allow: private, provider: userPools }])
  4. In the other schema file, declare a custom query using extend type Query { ... }
  5. Add an @auth rule like above.
  6. Run amplify build
  7. Observe in compiled schema.graphql file that the auth directives are missing from the second custom query:
customQueryOne: [Obj] @aws_iam @aws_cognito_user_pools
customQueryTwo: [AnotherObj]

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@matt-at-allera 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
@AnilMaktala
Copy link
Member

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.

@AnilMaktala AnilMaktala added question Further information is requested pending-community-response Issue is pending a response from the author or community. labels Nov 25, 2024
@AnilMaktala
Copy link
Member

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.

type Query {
  myCustomQuery2(args: String): String
  getTodo(id: ID!): Todo @aws_cognito_user_pools
  listTodos(filter: ModelTodoFilterInput, limit: Int, nextToken: String): ModelTodoConnection @aws_cognito_user_pools
  getTodo2(id: ID!): Todo2 @aws_cognito_user_pools
  listTodo2s(filter: ModelTodo2FilterInput, limit: Int, nextToken: String): ModelTodo2Connection @aws_cognito_user_pools
  myCustomQuery(args: String): String @aws_cognito_user_pools
}

@AnilMaktala AnilMaktala added bug Something isn't working and removed question Further information is requested pending-triage labels Nov 25, 2024
@palpatim palpatim self-assigned this Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-graphql bug Something isn't working pending-community-response Issue is pending a response from the author or community.
Projects
None yet
Development

No branches or pull requests

3 participants