question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple GraphQL endpoints not working

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:20 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Diizzayycommented, Oct 18, 2022
1reaction
Diizzayycommented, Oct 18, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQl Multiple Endpoints not working · Issue #721 - GitHub
Current behavior. When adding multiple endpoints for graphql it gives following weird error. (node:16316) UnhandledPromiseRejectionWarning: ...
Read more >
When to use multiple endpoints in GraphQL - LogRocket Blog
The idea is to define several GraphQL schemas, and tell the server which one to use on runtime, based on the requested endpoint....
Read more >
Using multiple endpoints in Apollo Client - Stack Overflow
Currently, I am building my own project using Next.js which required fetching data from 2 GraphQL endpoints. My problem: How can I fetch...
Read more >
Using Apollo with multiple Graphql endpoints
Using Apollo with multiple Graphql endpoints · 1- Create HttpLink to each endpoint · 2- Configure Apollo client · 3- finally, when you...
Read more >
3 methods to resolve GraphQL endpoints - Contentful
The biggest issues with direct data access are organizational boundaries and ownership. Where REST-based architectures allow multiple teams to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found