Skip to content

Feat: add support for graphql@16.x.x #1383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 73 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
},
"peerDependencies": {
"class-validator": ">=0.12.0",
"graphql": "^15.5.0"
"graphql": ">=15.5.0"
},
"dependencies": {
"@types/glob": "^7.1.3",
"@types/node": "*",
"@types/semver": "^7.3.4",
"glob": "^7.1.6",
"graphql-query-complexity": "^0.7.2",
"graphql-subscriptions": "^1.2.0",
"graphql-subscriptions": "^2.0.0",
"semver": "^7.3.4",
"tslib": "^2.1.0"
},
Expand All @@ -52,7 +52,7 @@
"apollo-server-plugin-response-cache": "^0.6.0",
"class-validator": "^0.13.1",
"del": "^6.0.0",
"graphql": "^15.5.0",
"graphql": "^16.6.0",
"graphql-redis-subscriptions": "^2.3.1",
"graphql-tag": "^2.11.0",
"gulp-replace": "^1.0.0",
Expand Down
8 changes: 6 additions & 2 deletions src/schema/schema-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ export abstract class SchemaGenerator {
static async generateFromMetadata(options: SchemaGeneratorOptions): Promise<GraphQLSchema> {
const schema = this.generateFromMetadataSync(options);
if (!options.skipCheck) {
const { errors } = await graphql(schema, getIntrospectionQuery());
const { errors } = await graphql({
schema,
source: getIntrospectionQuery(),
});

Comment on lines +117 to +121
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (errors) {
throw new GeneratingSchemaError(errors);
}
Expand Down Expand Up @@ -855,7 +859,7 @@ export abstract class SchemaGenerator {
return async (...args) => {
const resolvedType = await resolveType(...args);
if (!resolvedType || typeof resolvedType === "string") {
return resolvedType;
return resolvedType || undefined;
}
return possibleObjectTypesInfo.find(objectType => objectType.target === resolvedType)?.type
.name;
Expand Down
8 changes: 3 additions & 5 deletions src/utils/emitSchemaDefinitionFile.ts
Original file line number Diff line number Diff line change
@@ -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<GraphQLPrintSchemaOptions> {
export interface PrintSchemaOptions {
sortedSchema: boolean;
}

export const defaultPrintSchemaOptions: PrintSchemaOptions = {
commentDescriptions: false,
sortedSchema: true,
};

Expand Down Expand Up @@ -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);
}
Loading