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

Console: Remote schema permissions does not properly handle arguments for non-root fields #8898

Closed
harishnair96 opened this issue Sep 1, 2022 · 2 comments
Labels
k/bug Something isn't working t/gql-services

Comments

@harishnair96
Copy link
Contributor

Version Information

Server Version: 2.11.1

Environment

OSS

What is the current behaviour?

If the non-root field of a remote schema has an argument, setting remote schema permission for that field does not include the argument. This has the effect that roles other than admin role won't be able to use that argument.

What is the expected behaviour?

Setting permission on a field must include any arguments that field contains similar to how arguments for root fields are handled.

How to reproduce the issue?

  1. Connect a remote schema to Hasura that has the following GraphQL schema:
type Book {
  title: String
  author: String
  category: Category
}

type Author {
  name: String
  books(category: Category): [Book]
}

enum Category { science, fiction }

type Query {
  authors: [Author]
}
  1. Add a permission to that remote schema as shown in the image below:

add_permission

  1. Execute the following GraphQL query for the admin role -
{
  authors {
    books(category: fiction) {
      title
    }
  }
}
  1. Execute the same GraphQL query for the user role and observer the error -
{
  "errors": [
    {
      "extensions": {
        "code": "validation-failed",
        "path": "$.selectionSet.authors.selectionSet.books"
      },
      "message": "'books' has no argument named 'category'"
    }
  ]
}

Any possible solutions?

The issue happens because console does not send the proper schema to the backend. Therefore, the permissions for remote schema in the metadata will have the following GraphQL type -

type Author {
  books: [Book]
  name: String
}

when it should have been -

type Author {
  books(category: Category): [Book]
  name: String
}

Sending the proper schema to the backend would fix the problem.

Keywords

remote schema permission

@harishnair96 harishnair96 added the k/bug Something isn't working label Sep 1, 2022
@harishnair96
Copy link
Contributor Author

The workaround for this issue is to edit the metadata manually to use the correct type.

@rahulagarwal13
Copy link
Contributor

fixed in 2.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k/bug Something isn't working t/gql-services
Projects
None yet
Development

No branches or pull requests

3 participants