1 | import { MapperKind, mapSchema } from '@graphql-tools/utils';
|
2 |
|
3 | export function checkForResolveTypeResolver(schema, requireResolversForResolveType) {
|
4 | mapSchema(schema, {
|
5 | [MapperKind.ABSTRACT_TYPE]: type => {
|
6 | if (!type.resolveType) {
|
7 | const message = `Type "${type.name}" is missing a "__resolveType" resolver. Pass 'ignore' into ` +
|
8 | '"resolverValidationOptions.requireResolversForResolveType" to disable this error.';
|
9 | if (requireResolversForResolveType === 'error') {
|
10 | throw new Error(message);
|
11 | }
|
12 | if (requireResolversForResolveType === 'warn') {
|
13 | console.warn(message);
|
14 | }
|
15 | }
|
16 | return undefined;
|
17 | },
|
18 | });
|
19 | }
|