graphql-mesh icon indicating copy to clipboard operation
graphql-mesh copied to clipboard

graphql-mesh/compose cannot consume graph generated by itself

Open jakub-holy-juicymo-cz opened this issue 9 months ago • 3 comments

Issue workflow progress

Progress of the issue based on the Contributor Workflow

Describe the bug

graphql-mesh/compose cannot consume graph generated by itself

To Reproduce Steps to reproduce the behavior:

run:

$ npm i @graphql-mesh/compose-cli
$ npm i @graphql-hive/gateway

create 2 files:

mesh.orig.ts

import {
  defineConfig,
  loadGraphQLHTTPSubgraph
} from '@graphql-mesh/compose-cli'

export const composeConfig = defineConfig({
  subgraphs: [
    /**/{
      sourceHandler: loadGraphQLHTTPSubgraph('MortyB', {
        endpoint: 'https://rickandmortyapi.com/graphql'

      }),
    },
  ]
})

mesh.hive.ts

import {
  defineConfig,
  loadGraphQLHTTPSubgraph
} from '@graphql-mesh/compose-cli'

export const composeConfig = defineConfig({
  subgraphs: [
    /**/{
      sourceHandler: loadGraphQLHTTPSubgraph('MortyB', {
        endpoint: 'http://localhost:5001/graphql'

      }),
    },
  ]
})

run following

$ npx mesh-compose -c mesh.orig.ts -o supergraph_orig.graphql
$ npx hive-gateway -p 5001 supergraph_orig

in other terminal run

$ npx mesh-compose -c mesh.hive.ts -o supergraph_hive.graphql

error message:

ERROR [Mesh Compose, subgraph=MortyB]  Schema must contain uniquely named types but contains multiple types named "TransportOptions".
ERROR [Mesh Compose, subgraph=MortyB]  Failed to load subgraph

Expected behavior

The graph can be composed and used

jakub-holy-juicymo-cz avatar Mar 27 '25 16:03 jakub-holy-juicymo-cz

Sorry I didn't understand the setup you have. Could you please create a reproduction on CodeSandbox? Thanks!

ardatan avatar Mar 27 '25 16:03 ardatan

https://codesandbox.io/p/devbox/thirsty-fog-88k2gk?workspaceId=ws_Rx9GNSkTDnZhrmVKawUzZK

there are two commands, "start" is the started server, and "start2" tries to extract graphql from it and compose it ...

my final goal is to be able to chain supergraphs into supersupergraph, possibly even to supersupersupergraph :-)

jakub-holy-juicymo-cz avatar Mar 28 '25 09:03 jakub-holy-juicymo-cz

Unfortunatrly that kind of chaining is not possible today

ardatan avatar Mar 28 '25 09:03 ardatan