From 2727ec4343af1ba88479dcc7bc9523f739dbf88c Mon Sep 17 00:00:00 2001 From: Geoffrey Hervet Date: Fri, 18 Nov 2022 17:44:04 +0100 Subject: [PATCH] chore: remove commentDescriptions support For more informations, please refer to: https://github.com/graphql/graphql-js/pull/2900 --- src/utils/emitSchemaDefinitionFile.ts | 8 +++----- tests/functional/emit-schema-sdl.ts | 24 ++++-------------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/utils/emitSchemaDefinitionFile.ts b/src/utils/emitSchemaDefinitionFile.ts index 2da48bf33..805109845 100644 --- a/src/utils/emitSchemaDefinitionFile.ts +++ b/src/utils/emitSchemaDefinitionFile.ts @@ -1,14 +1,12 @@ -import { GraphQLSchema, printSchema, lexicographicSortSchema } from "graphql"; -import { Options as GraphQLPrintSchemaOptions } from "graphql/utilities/printSchema"; +import { GraphQLSchema, printSchema, lexicographicSortSchema, buildClientSchema } from "graphql"; import { outputFile, outputFileSync } from "../helpers/filesystem"; -export interface PrintSchemaOptions extends Required { +export interface PrintSchemaOptions { sortedSchema: boolean; } export const defaultPrintSchemaOptions: PrintSchemaOptions = { - commentDescriptions: false, sortedSchema: true, }; @@ -40,5 +38,5 @@ export async function emitSchemaDefinitionFile( function getSchemaFileContent(schema: GraphQLSchema, options: PrintSchemaOptions) { const schemaToEmit = options.sortedSchema ? lexicographicSortSchema(schema) : schema; - return generatedSchemaWarning + printSchema(schemaToEmit, options); + return generatedSchemaWarning + printSchema(schemaToEmit); } diff --git a/tests/functional/emit-schema-sdl.ts b/tests/functional/emit-schema-sdl.ts index edf9b77f2..0504c73a9 100644 --- a/tests/functional/emit-schema-sdl.ts +++ b/tests/functional/emit-schema-sdl.ts @@ -56,7 +56,7 @@ describe("Emitting schema definition file", () => { function checkSchemaSDL( SDL: string, - { commentDescriptions, sortedSchema }: PrintSchemaOptions = defaultPrintSchemaOptions, + { sortedSchema }: PrintSchemaOptions = defaultPrintSchemaOptions, ) { expect(SDL).toContain("THIS FILE WAS GENERATED"); expect(SDL).toContain("MyObject"); @@ -65,11 +65,7 @@ describe("Emitting schema definition file", () => { } else { expect(SDL.indexOf("descriptionProperty")).toBeGreaterThan(SDL.indexOf("normalProperty")); } - if (commentDescriptions) { - expect(SDL).toContain(`# Description test`); - } else { - expect(SDL).toContain(`"""Description test"""`); - } + expect(SDL).toContain(`"""Description test"""`); } describe("emitSchemaDefinitionFile", () => { @@ -83,7 +79,6 @@ describe("Emitting schema definition file", () => { it("should use provided options to write file with schema SDL", async () => { const targetPath = path.join(TEST_DIR, "schemas", "test1", "schema.gql"); const options: PrintSchemaOptions = { - commentDescriptions: true, sortedSchema: false, }; await emitSchemaDefinitionFile(targetPath, schema, options); @@ -129,7 +124,6 @@ describe("Emitting schema definition file", () => { it("should use provided options to write file with schema SDL", async () => { const targetPath = path.join(TEST_DIR, "schemas", "test1", "schema.gql"); const options: PrintSchemaOptions = { - commentDescriptions: true, sortedSchema: false, }; emitSchemaDefinitionFileSync(targetPath, schema, options); @@ -195,14 +189,12 @@ describe("Emitting schema definition file", () => { await buildSchema({ resolvers: [MyResolverClass], emitSchemaFile: { - commentDescriptions: true, path: targetPath, sortedSchema: false, }, }); expect(fs.existsSync(targetPath)).toEqual(true); checkSchemaSDL(fs.readFileSync(targetPath).toString(), { - commentDescriptions: true, sortedSchema: false, }); }); @@ -212,14 +204,11 @@ describe("Emitting schema definition file", () => { const targetPath = path.join(process.cwd(), "schema.gql"); await buildSchema({ resolvers: [MyResolverClass], - emitSchemaFile: { - commentDescriptions: true, - }, + emitSchemaFile: {}, }); expect(fs.existsSync(targetPath)).toEqual(true); checkSchemaSDL(fs.readFileSync(targetPath).toString(), { ...defaultPrintSchemaOptions, - commentDescriptions: true, }); }); }); @@ -251,14 +240,12 @@ describe("Emitting schema definition file", () => { buildSchemaSync({ resolvers: [MyResolverClass], emitSchemaFile: { - commentDescriptions: true, path: targetPath, sortedSchema: false, }, }); expect(fs.existsSync(targetPath)).toEqual(true); checkSchemaSDL(fs.readFileSync(targetPath).toString(), { - commentDescriptions: true, sortedSchema: false, }); }); @@ -268,14 +255,11 @@ describe("Emitting schema definition file", () => { const targetPath = path.join(process.cwd(), "schema.gql"); buildSchemaSync({ resolvers: [MyResolverClass], - emitSchemaFile: { - commentDescriptions: true, - }, + emitSchemaFile: {}, }); expect(fs.existsSync(targetPath)).toEqual(true); checkSchemaSDL(fs.readFileSync(targetPath).toString(), { ...defaultPrintSchemaOptions, - commentDescriptions: true, }); }); });