From 9ee939f503ab7124e06d7029510d187cdc9a4c92 Mon Sep 17 00:00:00 2001 From: Matthew Ratzke Date: Thu, 21 Dec 2023 16:30:24 -0700 Subject: [PATCH] fix: schema definition included in schema-first approach --- .../generated-definitions/federation-partial-query.fixture.ts | 4 ++++ .../tests/generated-definitions/federation-typedef.fixture.ts | 4 ++++ .../apollo/tests/generated-definitions/federation.fixture.ts | 4 ++++ .../lib/federation/graphql-federation-definitions.factory.ts | 3 ++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/apollo/tests/generated-definitions/federation-partial-query.fixture.ts b/packages/apollo/tests/generated-definitions/federation-partial-query.fixture.ts index b7b47b1e1..bb705ee5f 100644 --- a/packages/apollo/tests/generated-definitions/federation-partial-query.fixture.ts +++ b/packages/apollo/tests/generated-definitions/federation-partial-query.fixture.ts @@ -12,4 +12,8 @@ export interface IQuery { foo(): Nullable | Promise>; } +export interface ISchema { + Query: IQuery; +} + type Nullable = T | null; diff --git a/packages/apollo/tests/generated-definitions/federation-typedef.fixture.ts b/packages/apollo/tests/generated-definitions/federation-typedef.fixture.ts index 077085215..dec890816 100644 --- a/packages/apollo/tests/generated-definitions/federation-typedef.fixture.ts +++ b/packages/apollo/tests/generated-definitions/federation-typedef.fixture.ts @@ -33,4 +33,8 @@ export class User { posts?: Nullable[]>; } +export class ISchema { + Query: IQuery; +} + type Nullable = T | null; diff --git a/packages/apollo/tests/generated-definitions/federation.fixture.ts b/packages/apollo/tests/generated-definitions/federation.fixture.ts index c662cbee0..08e57c7e0 100644 --- a/packages/apollo/tests/generated-definitions/federation.fixture.ts +++ b/packages/apollo/tests/generated-definitions/federation.fixture.ts @@ -28,4 +28,8 @@ export class User { posts?: Nullable[]>; } +export class ISchema { + Query: IQuery; +} + type Nullable = T | null; diff --git a/packages/graphql/lib/federation/graphql-federation-definitions.factory.ts b/packages/graphql/lib/federation/graphql-federation-definitions.factory.ts index c005bcf65..5a9336c2a 100644 --- a/packages/graphql/lib/federation/graphql-federation-definitions.factory.ts +++ b/packages/graphql/lib/federation/graphql-federation-definitions.factory.ts @@ -41,7 +41,8 @@ export class GraphQLFederationDefinitionsFactory extends GraphQLDefinitionsFacto // This leads to duplicated IQuery interfaces // see: https://github.com//issues/2344 const mergedDefinition = mergeTypeDefs([printSubgraphSchema(schema)], { - useSchemaDefinition: false, + // schema-first requires the schema definition to be included for federation 2 @link to function + useSchemaDefinition: true, throwOnConflict: true, commentDescriptions: true, reverseDirectives: true,