Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
fix(filterSchema): should not modify original schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed Sep 17, 2019
1 parent c3bbeaf commit 9583011
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/transforms/filterSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from 'graphql';
import { GraphQLSchemaWithTransforms, VisitSchemaKind } from '../Interfaces';
import { visitSchema } from '../utils/visitSchema';
import { cloneSchema } from '../utils/clone';

export type RootFieldFilter = (
operation: 'Query' | 'Mutation' | 'Subscription',
Expand All @@ -31,7 +32,7 @@ export default function filterSchema({
typeFilter?: (typeName: string, type: GraphQLType) => boolean;
fieldFilter?: (typeName: string, fieldName: string) => boolean;
}): GraphQLSchemaWithTransforms {
const filteredSchema: GraphQLSchemaWithTransforms = visitSchema(schema, {
const filteredSchema: GraphQLSchemaWithTransforms = visitSchema(cloneSchema(schema), {
[VisitSchemaKind.QUERY]: (type: GraphQLObjectType) => {
return filterRootFields(type, 'Query', rootFieldFilter);
},
Expand Down

0 comments on commit 9583011

Please sign in to comment.