Skip to content
Discussion options

You must be logged in to vote

It should be pretty simple, you can create something like that as a custom plugin:

// my-plugin.js
const { printSchema, parse } = require('graphql');

module.exports = {
  plugin: (schema) => {
     const schemaStr = printSchema(schema);
     const schemaNode = parse(schemaStr);

     return `export const schema = ${JSON.stringify(schemaNode)}`;
  }
}

Then use it in codegen:

schema: "src/**/*.graphql" # point here to all your schema pieces, codegen will merge it for you
generates:
  ./schema.ts:
     plugins:
       - ./my-plugin.js

@affanshahid

For more info about custom plugins: https://graphql-code-generator.com/docs/custom-codegen/index

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dotansimha
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants