-
-
Notifications
You must be signed in to change notification settings - Fork 796
/
FilterInterfaceFields.ts
27 lines (21 loc) · 964 Bytes
/
FilterInterfaceFields.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
import { GraphQLSchema, GraphQLFieldConfig } from 'graphql';
import { FieldFilter } from '@graphql-tools/utils';
import { SubschemaConfig, Transform } from '@graphql-tools/delegate';
import TransformInterfaceFields from './TransformInterfaceFields';
export default class FilterInterfaceFields implements Transform {
private readonly transformer: TransformInterfaceFields;
constructor(filter: FieldFilter) {
this.transformer = new TransformInterfaceFields(
(typeName: string, fieldName: string, fieldConfig: GraphQLFieldConfig<any, any>) =>
filter(typeName, fieldName, fieldConfig) ? undefined : null
);
}
public transformSchema(
originalWrappingSchema: GraphQLSchema,
subschemaConfig?: SubschemaConfig,
transforms?: Array<Transform>,
transformedSchema?: GraphQLSchema
): GraphQLSchema {
return this.transformer.transformSchema(originalWrappingSchema, subschemaConfig, transforms, transformedSchema);
}
}