Skip to content

Commit

Permalink
fix(wrap): GraphQL v14 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Apr 6, 2023
1 parent 61f040c commit c8d5e0d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-beds-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/wrap': patch
---

Fix GraphQL v14 support
6 changes: 3 additions & 3 deletions packages/wrap/src/transforms/MoveRootField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export class MoveRootField implements Transform {
public transformSchema(schema: GraphQLSchema, _subschemaConfig: Record<string, any>): GraphQLSchema {
const rootTypeMap = getRootTypeMap(schema);
const newRootFieldsMap: Record<OperationTypeNode, GraphQLFieldConfigMap<any, any>> = {
query: rootTypeMap.get(OperationTypeNode.QUERY)?.toConfig()?.fields || {},
mutation: rootTypeMap.get(OperationTypeNode.MUTATION)?.toConfig()?.fields || {},
subscription: rootTypeMap.get(OperationTypeNode.SUBSCRIPTION)?.toConfig()?.fields || {},
query: rootTypeMap.get('query' as OperationTypeNode)?.toConfig()?.fields || {},
mutation: rootTypeMap.get('mutation' as OperationTypeNode)?.toConfig()?.fields || {},
subscription: rootTypeMap.get('subscription' as OperationTypeNode)?.toConfig()?.fields || {},
};
for (const operation in this.from) {
const removedFields = this.from[operation as OperationTypeNode];
Expand Down
4 changes: 2 additions & 2 deletions packages/wrap/tests/moveRootField.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('MoveRootField', () => {
transforms: [
new MoveRootField({
query: {
foo: OperationTypeNode.MUTATION,
foo: 'mutation' as OperationTypeNode,
},
mutation: {},
subscription: {},
Expand Down Expand Up @@ -60,7 +60,7 @@ describe('MoveRootField', () => {
transforms: [
new MoveRootField({
query: {
foo: OperationTypeNode.MUTATION,
foo: 'mutation' as OperationTypeNode,
},
mutation: {},
subscription: {},
Expand Down

0 comments on commit c8d5e0d

Please sign in to comment.