Subject: [PATCH] trying to test, pt 2 --- Index: packages/delegate/tests/transforms.test.ts IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/packages/delegate/tests/transforms.test.ts b/packages/delegate/tests/transforms.test.ts --- a/packages/delegate/tests/transforms.test.ts (revision e7fe51cda2759232c90b6701ea11811d3a34cb18) +++ b/packages/delegate/tests/transforms.test.ts (date 1672845015190) @@ -1,7 +1,9 @@ -import { Subschema, delegateToSchema } from '@graphql-tools/delegate'; +import { Subschema, delegateToSchema, Transformer, DelegationContext } from '@graphql-tools/delegate'; import { makeExecutableSchema } from '@graphql-tools/schema'; import { RenameRootFields, RenameObjectFields } from '@graphql-tools/wrap'; import { graphql, GraphQLSchema } from 'graphql'; +import { bookingSchema } from '../../testing/fixtures/schemas'; +import { parse } from 'graphql/index'; describe('can delegate to subschema with transforms', () => { let sourceSchema: GraphQLSchema; @@ -132,3 +134,55 @@ }); }); }); + +describe('test my breakage', () => { + test('should not kick out fragments on root', async () => { + const query = parse(/* GraphQL */ ` + mutation MyMutation { + testMutation { + query { + ...FooingFragment + } + } + } + + fragment FooingFragment on Query { + foo { + ... on Fooing { + pk + } + ... on Bar { + bar + } + + ... on Baz { + baz + } + } + } + `); + const context = { + targetSchema: bookingSchema, + transforms: [], + } as unknown as DelegationContext; + const transformer = new Transformer(context); + + const result = transformer.transformRequest({ + document: query, + variables: {}, + }); + + expect(result).toEqual({ + data: { + item: 'TRANSFORMED_ITEM', + items: { + edges: [ + { + node: 'TRANSFORMED_ITEM', + }, + ], + }, + }, + }); + }); +});