-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Codegen] Defining multiple schema's #1199
Comments
Hi! Can you try changing the Let me know if that works. |
Thanks for the reply! It's indeed for now the only option to split the queries into separate directories so Codegen is able to generate the type files for us. I will share my final working config here for anyone else that ran into this issue. Feel free to use it: import type { CodegenConfig } from '@graphql-codegen/cli';
import { pluckConfig, preset, schema } from '@shopify/hydrogen-codegen';
const contentfulSchema = {
[`https://graphql.contentful.com/content/v1/spaces/${process.env.CONTENTFUL_SPACE_ID}`]:
{
headers: {
Authorization: `Bearer ${process.env.CONTENTFUL_ACCESS_TOKEN}`,
},
},
};
const eslintDisable = `/* eslint-disable eslint-comments/disable-enable-pair */\n/* eslint-disable eslint-comments/no-unlimited-disable */\n/* eslint-disable */`;
export default {
overwrite: true,
pluckConfig,
generates: {
'storefrontapi.generated.d.ts': {
schema,
preset,
documents: [
'app/**/graphql/shopify/*.{ts,tsx}',
'app/**/graphql/shopify/*/*.{ts,tsx}',
],
},
'contentful.generated.d.ts': {
schema: contentfulSchema,
plugins: [
'typescript',
'typescript-operations',
{
add: {
content: eslintDisable,
},
},
],
documents: [
'app/**/graphql/contentful/*.{ts,tsx}',
'app/**/graphql/contentful/*/*.{ts,tsx}',
],
},
},
} as CodegenConfig; |
Which package or tool is having this issue?
Hydrogen
What version of that package or tool are you using?
2023.7.1
What version of Remix are you using?
1.19.1
Issue
The
codegen-unstable
is a great way to generate types on the fly and speed up your development.When staying within the Storefront API domain it works like a charm but at the moment it's not possible to expand this beyond that because you will run into multiple issue's.
Steps to reproduce:
codegen.ts
I have removed the API key and space Id in this example, but you get the idea: I would like to make two seperate files, one with the Storefront types and one with the Contentful types (or merging them into one large file).
This feature is possible read more about it here
pluckConfig
does some additional stuff and change the config in a way that you cannot undo. You can verify this by doing:As you can see I have commented out the Hydrogen part, Now the types for Contentful are working as expected but the storefront types are missing.
Expected Behavior
Just like the official implementation, you should be able to define multiple schema's.
Actual Behavior
Codegen will crash showing multiple (random) errors and not generating anything at all.
The text was updated successfully, but these errors were encountered: