nuxt-graphql-client: Multiple GraphQL endpoints not working

Hi all,

Long time reader, first time poster.

I’m trying to get this to work in my nuxt app with a connection to shopify and a local graphql api but not having much luck so far. Both the Shopify and local API work in postman respectively and i can call various queries in both, but as soon as I add them both in my config like the below:

runtimeConfig: {
    public: {
      JWT_SECRET: process.env.JWT_SECRET,
      gql: {
        clients: {
          shopify: {
            default: true,
            host: 'https://zzz.myshopify.com/api/2022-07/graphql.json',
            token: {
              name: 'X-Shopify-Storefront-Access-Token',
              value: 'zzzz', 
              type: null 
            },
            retainToken: true
          },
          concord: {
            host: `http://localhost:8080/graphql`,
            value: 'zzzzzzz'
          }          
        }
      }
    }
  }

In queries/shopify/cartCreate.gql along with a few other queries for shopify stuff

mutation cartCreate {
    cartCreate {
        cart {
            checkoutUrl
            id
        }
        userErrors {
            field
            message
        }
    }
}

In queries/concord/test.gql folder I just have 1 query

query concord_test {
  diamondProductsExternal {
    edges {
      node {
        shape
        id
      }
    }
  }
}

I get this error. Not really sure whats going on here as I can’t find anything about PageInfo anywhere. Could it be something cached. Is there a way to clear the build cache or something like that?

Cannot start nuxt:                                                                                                                                                                                                                                                        16:25:40
        Failed to load schema from https://zzz.myshopify.com/api/2022-07/graphql.json,http://localhost:8080/graphql:

        Unable to merge GraphQL type "PageInfo": Field "endCursor" already defined with a different type. Declared as "ConnectionCursor", but you tried to override with "String"
        Error: Unable to merge GraphQL type "PageInfo": Field "endCursor" already defined with a different type. Declared as "ConnectionCursor", but you tried to override with "String"
    at mergeType (file:///D:/zzz/sf/node_modules/@graphql-tools/merge/esm/typedefs-mergers/type.js:23:19)
    at mergeGraphQLNodes (file:///D:/zzz/sf/node_modules/@graphql-tools/merge/esm/typedefs-mergers/merge-nodes.js:34:49)
    at mergeGraphQLTypes (file:///D:/zzz/sf/node_modules/@graphql-tools/merge/esm/typedefs-mergers/merge-typedefs.js:63:25)
    at mergeTypeDefs (file:///D:/zzz/sf/node_modules/@graphql-tools/merge/esm/typedefs-mergers/merge-typedefs.js:10:22)
    at makeExecutableSchema (file:///D:/zzz/sf/node_modules/@graphql-tools/schema/esm/makeExecutableSchema.js:69:32)
    at mergeSchemas (file:///D:/zzz/sf/node_modules/@graphql-tools/schema/esm/merge-schemas.js:29:12)
    at getSchemaFromSources (file:///D:/zzz/sf/node_modules/@graphql-tools/load/esm/schema.js:51:20)
    at loadSchema (file:///D:/zzz/sf/node_modules/@graphql-tools/load/esm/schema.js:16:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async loadSchema (file:///D:/zzz/sf/node_modules/@graphql-codegen/cli/esm/load.js:33:24)

        GraphQL Code Generator supports:
          - ES Modules and CommonJS exports (export as default or named export "schema")
          - Introspection JSON File
          - URL of GraphQL endpoint
          - Multiple files with type definitions (glob expression)
          - String in config file

        Try to use one of above options and run codegen again.

About this issue

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

Most upvoted comments

@blackspike @zync09 The support for multiple clients has been vastly improved in recent releases. Any feedback you guys may have would be appreciated.

@zync09 that worked great as a stop-gap thank you for your help! 👯‍♀️

Awesome thanks man I’ll try adding that this afternoon, legend!