Use schema-ast plugin to generate the graphql schema (#2538)

This commit is contained in:
Abdullah Hilson 2023-03-14 08:48:33 +01:00 committed by GitHub
parent 48fb75423a
commit 31fcd45fac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 16 deletions

View file

@ -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 - Extract permissions for subscription query - #3155 by @zaiste
- Add custom request headers to webhook form - #3107 by @2can - Add custom request headers to webhook form - #3107 by @2can
- Allow subscription query for sync events - #3099 by @2can - Allow subscription query for sync events - #3099 by @2can
- Simplify codegen configuration to generate the graphql schema - #2538 by @abumalick
## 3.4 ## 3.4

View file

@ -3,3 +3,6 @@ generates:
./introspection.json: ./introspection.json:
plugins: plugins:
- introspection - introspection
./schema.graphql:
plugins:
- schema-ast

View file

@ -284,7 +284,7 @@
"check-types": "tsc --noEmit", "check-types": "tsc --noEmit",
"extract-json-messages": "formatjs extract 'src/**/*.{ts,tsx}' --out-file locale/defaultMessages.json --format scripts/formatter.js", "extract-json-messages": "formatjs extract 'src/**/*.{ts,tsx}' --out-file locale/defaultMessages.json --format scripts/formatter.js",
"extract-messages": "npm run extract-json-messages", "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", "heroku-postbuild": "npm run build",
"serve:lhci": "cross-env NODE_ENV=production npm run server", "serve:lhci": "cross-env NODE_ENV=production npm run server",
"prestart": "npm run build-types", "prestart": "npm run build-types",

View file

@ -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");
});