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

Remote Schema Permissions Default Value Null leads to Validation Error #7772

Open
2start opened this issue Nov 3, 2021 · 1 comment
Open
Labels
k/bug Something isn't working

Comments

@2start
Copy link

2start commented Nov 3, 2021

Version Information

Server Version: 2.0.10
CLI Version (for CLI related issue): v3

Environment

OSS

What is the expected behaviour?

  1. I write a new mutation in a remote schema and Hasura recognizes the mutation.
  2. I activate remote schema permissions.
  3. The mutation can be executed via Hasura using the admin role.
  4. I can assign remote schema permissions to a new role that allows it to execute the mutation.

What is the current behaviour?

  1. I create a new role.
  2. I try to assign permissions to execute a new mutation.
  3. I receive the following error:
{
    "path": "$.args[1].args",
    "error": "validation for the given role-based schema failed because expected default value of input value: \"sale_price\"of input object \"upsert_wma_sale_by_metadata_uuid\" to be null but received ",
    "code": "validation-failed"
}

Speculation about the source of the problem

If I change sale_price to a required parameter everything works flawlessly. I.e. the fact that sale_price is optional leads to a problem. I assume that the explicit statement of the default value null in the schema causes the error because parameters are nullable by default. However, this should still work because it is valid GraphQL Syntax and the GraphQL Framework Graphene explicitly states the default value in the schema.

  upsert_wma_sale_by_metadata_uuid(is_sold: Boolean!, metadata_uuid: uuid!, sale_price: Float = null): UpsertWmaSaleByMetadataUuid

@2start 2start added the k/bug Something isn't working label Nov 3, 2021
@jasonprado
Copy link

jasonprado commented Feb 4, 2022

I'm hitting this when trying to wrap a strapi GraphQL API in a Remote Schema. By default any collection type in strapi adds this to the schema: pagination: PaginationArg = {}. When this gets read by graphql-engine, it seems to turn into pagination: PaginationArg = undefined, and then saving permissions hits an error.

A solution with strapi is to use patch-package to modify node_modules/@strapi/plugin-graphql/server/services/internals/args/pagination.js and give PaginationArg a non-empty default argument.

Original:

module.exports = arg({
  type: PaginationInputType,
  default: {},
});

Replaced:

module.exports = arg({
  type: PaginationInputType,
  default: {limit:100},
});

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
Projects
None yet
Development

No branches or pull requests

2 participants