Skip to content

Commit c498fc3

Browse files
fix(): support gql v16
1 parent 4fda9d8 commit c498fc3

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

packages/graphql/lib/schema-builder/graphql-schema.factory.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { Injectable, Logger, Type } from '@nestjs/common';
22
import { isEmpty, isFunction } from '@nestjs/common/utils/shared.utils';
3-
import { getIntrospectionQuery, graphql, GraphQLSchema } from 'graphql';
3+
import {
4+
getIntrospectionQuery,
5+
graphql,
6+
GraphQLError,
7+
GraphQLSchema,
8+
version as GraphQLPackageVersion,
9+
} from 'graphql';
410
import {
511
SCALAR_NAME_METADATA,
612
SCALAR_TYPE_METADATA,
@@ -69,7 +75,17 @@ export class GraphQLSchemaFactory {
6975

7076
if (!options.skipCheck) {
7177
const introspectionQuery = getIntrospectionQuery();
72-
const { errors } = await graphql(schema, introspectionQuery);
78+
let errors: readonly GraphQLError[];
79+
if (GraphQLPackageVersion.startsWith('15')) {
80+
const executionResult = await graphql(schema, introspectionQuery);
81+
errors = executionResult.errors;
82+
} else {
83+
const executionResult = await graphql({
84+
schema,
85+
source: introspectionQuery,
86+
});
87+
errors = executionResult.errors;
88+
}
7389
if (errors) {
7490
throw new SchemaGenerationError(errors);
7591
}

0 commit comments

Comments
 (0)