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

Rename & Encapsulate Transforms On GraphQL Handler Break Query #1600

Open
ddcollins opened this issue Feb 12, 2021 · 1 comment
Open

Rename & Encapsulate Transforms On GraphQL Handler Break Query #1600

ddcollins opened this issue Feb 12, 2021 · 1 comment

Comments

@ddcollins
Copy link

ddcollins commented Feb 12, 2021

Describe the bug
I've attempted to use the encapsulate and rename transform on my GraphQL source, and each result in an error at query time.

sources:
  - name: Academy
    transforms:
      - filterSchema:
          - Query.!server
      - encapsulate:
          applyTo:
            query: true
            mutation: false
            subscription: false
    handler:
      graphql:
        endpoint: ${DIRECTUS_HOST}
        schemaHeaders:
          Authorization: Bearer ${DIRECTUS_API_TOKEN}
        operationHeaders:
          Authorization: Bearer ${DIRECTUS_API_TOKEN}
        batch: false
additionalTypeDefs:
  - ./src/additional-type-definitions.graphql
additionalResolvers:
  - ./src/additional-resolvers.js

transforms:
  # Global
  - resolversComposition:
      - resolver: 'Query.*'
        composer: ./src/middleware/api-token-guard.js
      - resolver: 'Mutation.*'
        composer: ./src/middleware/api-token-guard.js
  - namingConvention:
      # Causes issue with union types
      # typeNames: pascalCase
      enumValues: upperCase
      fieldNames: camelCase
{
    academy {
        items {
            course(limit:10) {
                id
                title
                description
            }
        }
    }
}
{
            "message": "Cannot read property 'columns' of undefined",
            "name": "GraphQLError",
            "originalError": {},
            "path": [
                "academy",
                "course"
            ],
            "source": {
                "locationOffset": {}
            },
            "stack": [
                "GraphQLError: Cannot read property 'columns' of undefined",
                "    at Object.relocatedError (/app/node_modules/@graphql-tools/utils/index.cjs.js:3894:12)",
                "    at mergeDataAndErrors (/app/node_modules/@graphql-tools/delegate/index.cjs.js:1397:34)",
                "    at /app/node_modules/@graphql-tools/delegate/index.cjs.js:1425:66",
                "    at Array.forEach (<anonymous>)",
                "    at mergeDataAndErrors (/app/node_modules/@graphql-tools/delegate/index.cjs.js:1423:27)",
                "    at checkResultAndHandleErrors (/app/node_modules/@graphql-tools/delegate/index.cjs.js:1386:38)",
                "    at CheckResultAndHandleErrors.transformResult (/app/node_modules/@graphql-tools/delegate/index.cjs.js:1382:16)",
                "    at /app/node_modules/@graphql-tools/delegate/index.cjs.js:1569:40",
                "    at Array.reduceRight (<anonymous>)",
                "    at Transformer.transformResult (/app/node_modules/@graphql-tools/delegate/index.cjs.js:1568:37)"
            ]
        }

To Reproduce
Steps to reproduce the behavior:

  • Encapsulate or rename a top level field in GraphQL handler.
 - name: Academy
   transforms:
     - filterSchema:
        - Query.!server
     - encapsulate:
         name: Academy
         applyTo:
           query: true
           mutation: false
           subscription: false
 - name: Academy
   transforms:
     - filterSchema:
         - Query.!server
     - rename:
         - from:
             type: Query
             field: items
           to:
             type: Query
             field: academy
  • Fire off a query.

Expected behavior
Query executes successfully.

Environment:

  • OS: MacOS 10.15.7
   "@graphql-mesh/cli": "^0.15.*",
   "@graphql-mesh/graphql": "^0.13.13",
   "@graphql-mesh/json-schema": "^0.10.2",
   "@graphql-mesh/transform-encapsulate": "^0.1.23",
   "@graphql-mesh/transform-filter-schema": "^0.8.27",
   "@graphql-mesh/transform-naming-convention": "^0.6.26",
   "@graphql-mesh/transform-rename": "^0.7.21",
   "@graphql-mesh/transform-resolvers-composition": "^0.7.26"
  • NodeJS: 14.15

Additional context

@ddcollins
Copy link
Author

@ardatan Here's a repo I set up with instructions on how to replicate this! https://github.com/ddcollins/mesh-directus-replication.

@theguild-bot theguild-bot mentioned this issue Aug 11, 2022
@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
klippx pushed a commit to klippx/graphql-mesh that referenced this issue Oct 9, 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

1 participant