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

Mesh uses pre-transformed schema to process variables #5010

Closed
uzair-inamdar opened this issue Jan 10, 2023 · 2 comments
Closed

Mesh uses pre-transformed schema to process variables #5010

uzair-inamdar opened this issue Jan 10, 2023 · 2 comments

Comments

@uzair-inamdar
Copy link
Contributor

    "@graphql-mesh/cli": "^0.82.9",
    "@graphql-mesh/openapi": "^0.35.6",
    "@graphql-mesh/transform-naming-convention": "^0.13.5",
    "@graphql-mesh/transform-rename": "^0.14.5"

The rough structure of .meshrc.yml is:

sources:
    - name: REST Source
       handler:
           openapi:
               ...
      transforms:
          - rename:
                 mode: bare
                 renames:
                     ....
transforms:
    - namingConvention:
           mode: wrap
               ... 

The error that I get comes from:
https://github.com/graphql/graphql-js/blob/505d096cf6586dc9af0eee50217683d9dd619b53/src/execution/values.ts#L88

    if (!isInputType(varType)) {
      // Must use input types for variables. This should be caught during
      // validation, however is checked again here for safety.
      const varTypeStr = print(varDefNode.type);
      onError(
        new GraphQLError(
          `Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`,
          { nodes: varDefNode.type },
        ),
      );
      continue;
    }

varType is undefined as it cannot be found in the schema.

After some debugging, I realized the culprit to be:
https://github.com/Urigo/graphql-mesh/blob/3922733355cbb7aa6432a718399da740a34c0ce6/packages/handlers/openapi/src/index.ts#L117
The schema passed from here to the execution layer of GraphQL code is the one that is generated before any transformation is applied. And so any renamed input in the .meshrc.yml are not able to be found in the pre-transformed schema, and hence we I get the above mentioned error.

In an older version of Mesh/OpenAPI handler that I was using, I saw that the schema being passed to the execution layer is the correct transformed schema, which confirms my suspicion the problem is the schema passed to value.ts of GraphQL.js.

@ardatan
Copy link
Owner

ardatan commented Feb 13, 2023

Could you try with wrap mode? Thanks!

@ardatan
Copy link
Owner

ardatan commented Apr 3, 2023

Closing the issue due to the inactivity.

@ardatan ardatan closed this as completed Apr 3, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants