Skip to content

Commit d6b77b9

Browse files
committed
feat: create schema file config interface and migrate use fed2 to it
1 parent 87cdb1c commit d6b77b9

File tree

3 files changed

+43
-31
lines changed

3 files changed

+43
-31
lines changed

packages/graphql/lib/interfaces/gql-module-options.interface.ts

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,10 @@ import { GraphQLSchema } from 'graphql';
55
import { GraphQLDriver } from '.';
66
import { DefinitionsGeneratorOptions } from '../graphql-ast.explorer';
77
import { BuildSchemaOptions } from './build-schema-options.interface';
8+
import { AutoSchemaFileValue } from './schema-file-config.interface';
89

910
export type Enhancer = 'guards' | 'interceptors' | 'filters';
1011

11-
export interface AliasDirectiveImport {
12-
name: string;
13-
as: string;
14-
}
15-
16-
export interface Federation2Config {
17-
/**
18-
* The imported directives
19-
* @default ['@key', '@shareable', '@external', '@override', '@requires']
20-
*/
21-
directives?: (string | AliasDirectiveImport)[];
22-
/**
23-
* The import link
24-
* @default 'https://specs.apollo.dev/federation/v2.0'
25-
*/
26-
importUrl?: string;
27-
}
28-
2912
/**
3013
* "GraphQLModule" options object.
3114
*/
@@ -55,18 +38,6 @@ export interface GqlModuleOptions<TDriver extends GraphQLDriver = any> {
5538
*/
5639
include?: Function[];
5740

58-
/**
59-
* If enabled, it will use federation 2 schema
60-
*
61-
* **Note:** You need to have installed @apollo/subgraph@^2.0.0 and enable `autoSchemaFile`
62-
*
63-
* This will add to your schema:
64-
* ```graphql
65-
extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key", "@shareable", "@external", "@override", "@requires"])
66-
* ```
67-
*/
68-
useFed2?: boolean | Federation2Config;
69-
7041
/**
7142
* Directive resolvers
7243
*/
@@ -93,7 +64,7 @@ export interface GqlModuleOptions<TDriver extends GraphQLDriver = any> {
9364
/**
9465
* If enabled, GraphQL schema will be generated automatically
9566
*/
96-
autoSchemaFile?: string | boolean;
67+
autoSchemaFile?: AutoSchemaFileValue;
9768

9869
/**
9970
* Sort the schema lexicographically

packages/graphql/lib/interfaces/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ export * from './graphql-driver.interface';
1414
export * from './resolve-type-fn.interface';
1515
export * from './return-type-func.interface';
1616
export * from './build-federated-schema-options.interface';
17+
export * from './schema-file-config.interface';
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
export interface AliasDirectiveImport {
2+
name: string;
3+
as: string;
4+
}
5+
6+
export interface Federation2Config {
7+
/**
8+
* The imported directives
9+
* @default ['@key', '@shareable', '@external', '@override', '@requires']
10+
*/
11+
directives?: (string | AliasDirectiveImport)[];
12+
/**
13+
* The import link
14+
* @default 'https://specs.apollo.dev/federation/v2.0'
15+
*/
16+
importUrl?: string;
17+
}
18+
19+
export type UseFed2Value = boolean | Federation2Config;
20+
21+
export interface SchemaFileConfig {
22+
/**
23+
* If enabled, it will use federation 2 schema
24+
*
25+
* **Note:** You need to have installed @apollo/subgraph@^2.0.0 and enable `autoSchemaFile`
26+
*
27+
* This will add to your schema:
28+
* ```graphql
29+
extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key", "@shareable", "@external", "@override", "@requires"])
30+
* ```
31+
*/
32+
useFed2?: UseFed2Value;
33+
34+
/**
35+
* The path to the schema file
36+
*/
37+
path?: string;
38+
}
39+
40+
export type AutoSchemaFileValue = boolean | string | SchemaFileConfig;

0 commit comments

Comments
 (0)