I have a client that queries 2 endpoints. Now, how do I auto-generate types from 2 graphql schemas, when using 2 endpoints?
Scripts I used up until now (with standard 1 endpoint) uses Apollo codegen (source):
"schema": "npx apollo service:download --endpoint=http://localhost:8080/graphql graphql-schema.json",
"types": "npm run schema && apollo client:codegen --localSchemaFile=graphql-schema.json --variant=development --target=typescript --addTypename --queries=./src/**/*.graphql --useReadOnlyTypes --globalTypesFile=src/globalTypes.ts . && npm run prettier"
Possible solution is also generating 2 introspection schemas and then merging them together, I just didn't find how.
I'm also open to move to Graphql Code Generator.
Is there any example, guidance, or link please? Thank you
GraphQL Code Generator supports configuring multiple schemas by merging their definitions automatically for you.
You will find some documentation on this matter here: https://www.the-guild.dev/graphql/codegen/docs/config-reference/schema-field#multiple-schemas-and-client-side-schema
Please note that schema
can take an array of schema file paths or URLs.
Let us know if you need any guidance migrating from Apollo codegen.
Charly, from The Guild.