From 31fcd45facf981cb8fdca6541015dbcb9134c030 Mon Sep 17 00:00:00 2001 From: Abdullah Hilson Date: Tue, 14 Mar 2023 08:48:33 +0100 Subject: [PATCH] Use schema-ast plugin to generate the graphql schema (#2538) --- CHANGELOG.md | 1 + fetch-schema.yml | 3 +++ package.json | 2 +- scripts/build-schema.js | 15 --------------- 4 files changed, 5 insertions(+), 16 deletions(-) delete mode 100644 scripts/build-schema.js diff --git a/CHANGELOG.md b/CHANGELOG.md index eb6cdb5f7..4412f16e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ All notable, unreleased changes to this project will be documented in this file. - Extract permissions for subscription query - #3155 by @zaiste - Add custom request headers to webhook form - #3107 by @2can - Allow subscription query for sync events - #3099 by @2can +- Simplify codegen configuration to generate the graphql schema - #2538 by @abumalick ## 3.4 diff --git a/fetch-schema.yml b/fetch-schema.yml index 12a5b2b5f..00228d156 100644 --- a/fetch-schema.yml +++ b/fetch-schema.yml @@ -3,3 +3,6 @@ generates: ./introspection.json: plugins: - introspection + ./schema.graphql: + plugins: + - schema-ast diff --git a/package.json b/package.json index 40a3d4b84..c21fbe309 100644 --- a/package.json +++ b/package.json @@ -284,7 +284,7 @@ "check-types": "tsc --noEmit", "extract-json-messages": "formatjs extract 'src/**/*.{ts,tsx}' --out-file locale/defaultMessages.json --format scripts/formatter.js", "extract-messages": "npm run extract-json-messages", - "fetch-schema": "graphql-codegen --config ./fetch-schema.yml && node scripts/build-schema.js", + "fetch-schema": "graphql-codegen --config ./fetch-schema.yml", "heroku-postbuild": "npm run build", "serve:lhci": "cross-env NODE_ENV=production npm run server", "prestart": "npm run build-types", diff --git a/scripts/build-schema.js b/scripts/build-schema.js deleted file mode 100644 index d467fcb3a..000000000 --- a/scripts/build-schema.js +++ /dev/null @@ -1,15 +0,0 @@ -/* eslint-disable no-console */ -/* eslint-disable @typescript-eslint/no-var-requires */ -const fs = require("fs"); -const graphql = require("graphql"); -const schema = require("../introspection.json"); - -const clientSchema = graphql.buildClientSchema(schema); -const schemaString = graphql.printSchema(clientSchema); - -fs.writeFile("schema.graphql", schemaString, err => { - if (err) { - throw err; - } - console.log("🚀 Schema from instrospection built successfully\n"); -});