Skip to content

Instantly share code, notes, and snippets.

@ThaddeusJiang
Created July 26, 2023 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThaddeusJiang/5790b35eaff92441b2354cdbfcafc7c5 to your computer and use it in GitHub Desktop.
Save ThaddeusJiang/5790b35eaff92441b2354cdbfcafc7c5 to your computer and use it in GitHub Desktop.
Setup graphql-codegen in Apollo GraphQL Client and multiple graphql schema files
import { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
schema: "graphql-api/**/*.graphqls",
documents: ["src/**/*.tsx"],
generates: {
"./src/__generated__/": {
preset: "client",
plugins: [],
presetConfig: {
gqlTagName: "gql",
},
},
},
ignoreNoDocuments: true,
};
export default config;
{
"scripts": {
"generate": "graphql-codegen",
"prestart": "npm run generate",
"predev": "npm run generate"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment