-
-
Notifications
You must be signed in to change notification settings - Fork 796
/
GraphQLSubschema.ts
31 lines (25 loc) · 1.06 KB
/
GraphQLSubschema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { GraphQLSchema } from 'graphql';
import { Transform, applySchemaTransforms } from '@graphql-tools/utils';
import { SubschemaConfig, MergedTypeConfig, CreateProxyingResolverFn, Subscriber, Executor } from './types';
export function isSubschema(value: any): value is Subschema {
return Boolean((value as Subschema).transformedSchema);
}
export class Subschema {
public schema: GraphQLSchema;
public rootValue?: Record<string, any>;
public executor?: Executor;
public subscriber?: Subscriber;
public createProxyingResolver?: CreateProxyingResolverFn;
public transforms: Array<Transform>;
public transformedSchema: GraphQLSchema;
public merge?: Record<string, MergedTypeConfig>;
constructor(config: SubschemaConfig) {
this.schema = config.schema;
this.executor = config.executor;
this.subscriber = config.subscriber;
this.createProxyingResolver = config.createProxyingResolver;
this.transforms = config.transforms ?? [];
this.merge = config.merge;
this.transformedSchema = applySchemaTransforms(this.schema, this.transforms);
}
}