Skip to content

Commit 5bd95a5

Browse files
committed
fix(url-loader): graphql v15 support
1 parent c9dd85f commit 5bd95a5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.changeset/huge-boxes-say.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-tools/url-loader': patch
3+
---
4+
5+
Fix GraphQL v15 support

packages/loaders/url/src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { buildASTSchema, buildSchema, IntrospectionOptions } from 'graphql';
1+
import { buildASTSchema, buildSchema, GraphQLSchema, IntrospectionOptions } from 'graphql';
22
import WebSocket from 'isomorphic-ws';
33
import { buildGraphQLWSExecutor } from '@graphql-tools/executor-graphql-ws';
44
import {
@@ -15,6 +15,7 @@ import {
1515
BaseLoaderOptions,
1616
ExecutionRequest,
1717
Executor,
18+
getDefinedRootType,
1819
getOperationASTFromRequest,
1920
isUrl,
2021
Loader,
@@ -431,6 +432,13 @@ export class UrlLoader implements Loader<LoadFromUrlOptions> {
431432
executor,
432433
batch: options?.batch,
433434
});
435+
if (!('getRootType' in source.schema)) {
436+
Object.defineProperty(source.schema, 'getRootType', {
437+
value(this: GraphQLSchema, operation: any) {
438+
return getDefinedRootType(this, operation);
439+
},
440+
});
441+
}
434442
}
435443

436444
return [source];

0 commit comments

Comments
 (0)