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

[V1] Can't use "resolveTo" with type, query or field renaming #7742

Open
4 tasks
enan69500 opened this issue Oct 1, 2024 · 1 comment
Open
4 tasks

[V1] Can't use "resolveTo" with type, query or field renaming #7742

enan69500 opened this issue Oct 1, 2024 · 1 comment

Comments

@enan69500
Copy link

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

When use @resolveTo with renaming source OpenApi (And other i think), that's not working.

TypeDef without renaming =>
  additionalTypeDefs: `
    extend type PointOfSale {
        test: [MS_Agency_CicsAgencyResponse]
          @resolveTo(
            sourceName: "ms-agency"
            sourceTypeName: "Query"
            sourceFieldName: "getCicsByIdUsingGET"
            requiredSelectionSet: "{ agencyId }"
            sourceArgs: { agency_id: "{root.agencyId}" }
          )
    }
  ` 

==> Work

But my renaming =>

        createRenameTransform({
             typeRenamer: ({ typeName }) => {
                 switch (typeName) {
                     case "MS_Agency_AgencyResponse":
                         return "PointOfSale";
                     default:
                         return typeName;
                 }
             },
             fieldRenamer: ({ typeName, fieldName }) => {
                if(typeName === "MS_Agency_Query" && fieldName === "MS_Agency_getCicsByIdUsingGET") {
                    return "getCicsById";
                }
                return fieldName;
             },
         }),

So new typedef :

TypeDef without renaming =>
  additionalTypeDefs: `
    extend type PointOfSale {
        test: [MS_Agency_CicsAgencyResponse]
          @resolveTo(
            sourceName: "ms-agency"
            sourceTypeName: "Query"
            sourceFieldName: "getCicsById"
            requiredSelectionSet: "{ agencyId }"
            sourceArgs: { agency_id: "{root.agencyId}" }
          )
    }
  ` 

That's not working

Note : As you can see, even Query should be called MS_Agency_Query

To Reproduce Steps to reproduce the behavior:

See above

Expected behavior

Error: No field named "getCicsById" exists in the type Query from the source ms-agency
at resolve (file:///C:/Sources/test-gm/graphql-mesh-debug/node_modules/.pnpm/@graphql-mesh+utils@0.102.5_@graphql-mesh+cross-helpers@0.4.6_@graphql-tools[email protected]_gra_7udymn4ftqclyxdht2baqulwli/node_modules/@graphql-mesh/utils/esm/resolve-additional-resolvers.js:201:35)
at executeField (file:///C:/Sources/test-gm/graphql-mesh-debug/node_modules/.pnpm/@graphql-tools[email protected][email protected]/node_modules/@graphql-tools/executor/esm/execution/execute.js:317:24)
at executeFields (file:///C:/Sources/test-gm/graphql-mesh-debug/node_modules/.pnpm/@graphql-tools[email protected][email protected]/node_modules/@graphql-tools/executor/esm/execution/execute.js:265:28)
at collectAndExecuteSubfields (file:///C:/Sources/test-gm/graphql-mesh-debug/node_modules/.pnpm/@graphql-tools[email protected][email protected]/node_modules/@graphql-tools/executor/esm/execution/execute.js:694:23)
at completeObjectValue (file:///C:/Sources/test-gm/graphql-mesh-debug/node_modules/.pnpm/@graphql-tools[email protected][email protected]/node_modules/@graphql-tools/executor/esm/execution/execute.js:684:12)
at completeValue (file:///C:/Sources/test-gm/graphql-mesh-debug/node_modules/.pnpm/@graphql-tools[email protected][email protected]/node_modules/@graphql-tools/executor/esm/execution/execute.js:452:16)
at file:///C:/Sources/test-gm/graphql-mesh-debug/node_modules/.pnpm/@graphql-tools[email protected][email protected]/node_modules/@graphql-tools/executor/esm/execution/execute.js:320:49
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///C:/Sources/test-gm/graphql-mesh-debug/node_modules/.pnpm/@graphql-tools[email protected][email protected]/node_modules/@graphql-tools/executor/esm/execution/promiseForObject.js:15:35
at async Promise.all (index 0)

Environment:

  • OS: Windows
    "@graphql-hive/gateway": "^1.0.6",
    "@graphql-mesh/compose-cli": "^1.0.3",
    "@graphql-mesh/serve-cli": "^1.0.5",
    "@omnigraph/openapi": "^0.106.8",
    "@graphql-mesh/plugin-http-details-extensions": "^0.102.5",
    "@graphql-mesh/types": "^0.102.5",
  • NodeJS: 21

Additional context

@ardatan
Copy link
Owner

ardatan commented Nov 6, 2024

Thanks for creating the issue.
Could you share a reproduction on CodeSandbox?

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