-
-
Notifications
You must be signed in to change notification settings - Fork 814
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { | |
GraphQLString, | ||
GraphQLUnionType, | ||
parse, | ||
versionInfo, | ||
} from 'graphql'; | ||
import { expectJSON } from '../../__testUtils__/expectJSON.js'; | ||
import { execute, executeSync } from '../execute.js'; | ||
|
@@ -621,5 +622,14 @@ describe('Execute: Handles execution of abstract types', () => { | |
expectError({ forTypeName: undefined }).toEqual( | ||
'Abstract type "Pet" must resolve to an Object type at runtime for field "Query.pet" with value { __typename: undefined }, received "[]".', | ||
); | ||
|
||
if (versionInfo.major >= 16) { | ||
// FIXME: workaround since we can't inject resolveType into SDL | ||
// @ts-expect-error | ||
assertInterfaceType(schema.getType('Pet')).resolveType = () => schema.getType('Cat'); | ||
expectError({ forTypeName: undefined }).toEqual( | ||
'Support for returning GraphQLObjectType from resolveType was removed in [email protected] please return type name instead.', | ||
); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ import { | |
SchemaMetaFieldDef, | ||
TypeMetaFieldDef, | ||
TypeNameMetaFieldDef, | ||
versionInfo, | ||
} from 'graphql'; | ||
import { ValueOrPromise } from 'value-or-promise'; | ||
import { | ||
|
@@ -1234,7 +1235,13 @@ function ensureValidRuntimeType( | |
} | ||
|
||
// releases before 16.0.0 supported returning `GraphQLObjectType` from `resolveType` | ||
// TODO: remove in 17.0.0 release | ||
if (isObjectType(runtimeTypeName)) { | ||
if (versionInfo.major >= 16) { | ||
throw createGraphQLError( | ||
'Support for returning GraphQLObjectType from resolveType was removed in [email protected] please return type name instead.', | ||
); | ||
} | ||
runtimeTypeName = runtimeTypeName.name; | ||
} | ||
|
||
|