Skip to content

Instantly share code, notes, and snippets.

@JulienHe
Created September 5, 2022 02:06
Show Gist options
  • Save JulienHe/9381c916b79f4b5cd0c73b19e83d228b to your computer and use it in GitHub Desktop.
Save JulienHe/9381c916b79f4b5cd0c73b19e83d228b to your computer and use it in GitHub Desktop.
Typedefs plugin
const { printSchema } = require("graphql");
module.exports = {
plugin: (schema, documents, config) => {
const theSchema = printSchema(schema).replaceAll("`", "");
return [
"const typeDefs = /* GraphQL */ `",
theSchema,
"`;",
"export default typeDefs;",
].join("\n");
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment