graphql-mesh: @graphql-mesh/graphql does not pass through auth-headers.

When trying to pass through auth tokens through header context it does not .meshrc.yaml

sources:
  - name: GraphQLEndpoint
    handler:
      graphql:
        endpoint: http://localhost:8911/graphql
        operationHeaders:
          Authorization: "{context.headers.authorization}"
          "auth-provider": "{context.headers['auth-provider']}"

package.json

{
  "name": "graphql-mesh",
  "version": "1.0.0",
  "main": "index.js",
  "author": "Christopher Burns",
  "license": "MIT",
  "scripts": {
    "start": "mesh serve"
  },
  "dependencies": {
    "@graphql-mesh/cli": "^0.16.3",
    "@graphql-mesh/graphql": "^0.13.4",
    "@graphql-mesh/openapi": "^0.12.2",
    "@graphql-mesh/transform-prefix": "^0.6.17",
    "graphql": "^15.4.0"
  }
}

when console.log is called here

executor: async (params) => {
                const { executor } = await getExecutorAndSubscriberForParams(params, operationHeadersFactory, endpointFactory);
                console.log(params)
                return executor(params);
            },

it shows the auth token being passed in as rawHeaders array and [Symbol(kHeaders)]: {}

image

but it seems like its not being pass through into the apollo client. empty headers.

image

Thank you 😃

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 18 (5 by maintainers)

Most upvoted comments

Fixed in @graphql-mesh/graphql@0.13.6!

Turns out I was looking for schemaHeaders. All good. Thanks!

@Burnsy Thank you! I’ll write back soon!

@Burnsy If you share a reproduction in a repo or somewhere else, I could help you better.

Hello @ardatan

It looks like its still happening

Package.json

{
  "name": "graphql-mesh",
  "version": "1.0.0",
  "main": "index.js",
  "author": "Christopher Burns",
  "license": "MIT",
  "scripts": {
    "start": "mesh serve"
  },
  "dependencies": {
    "@graphql-mesh/cli": "^0.18.0",
    "@graphql-mesh/graphql": "^0.13.7",
    "@graphql-mesh/openapi": "^0.12.5",
    "@graphql-mesh/transform-prefix": "^0.6.20",
    "graphql": "^15.4.0"
  }
}


sources:
  - name: cms
    handler:
      graphql:
        endpoint: https://api-eu-central-1.graphcms.com/v2/xx/master
    transforms:
      - prefix:
          value: cms_
          includeRootOperations: true
  - name: Everfund
    handler:
      graphql:
        endpoint: http://localhost:8911/graphql
        operationHeaders:
          Authorization: "{context.headers.authorization}"
          "auth-provider": "{context.headers['auth-provider']}"


serve:
  port: 4000
  cors:
    origin: "*"
    credentials: true