Skip to content

Commit

Permalink
allow MapFields to transform all field nodes (#1545)
Browse files Browse the repository at this point in the history
MapFields (really should be MapFieldNodes, this should be changed in next major release) currently provides a quick way to modify field nodes for object types by specification of a map of type/field names as opposed to a function.

this backwards-compatible change allows MapFields to also work for interfaces and root types.
  • Loading branch information
yaacovCR committed May 27, 2020
1 parent 02c9b1a commit 5d8aad8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/wrap/src/transforms/MapFields.ts
Expand Up @@ -2,13 +2,13 @@ import { GraphQLSchema } from 'graphql';

import { Transform, Request, FieldNodeMappers } from '@graphql-tools/utils';

import TransformObjectFields from './TransformObjectFields';
import TransformCompositeFields from './TransformCompositeFields';

export default class MapFields implements Transform {
private readonly transformer: TransformObjectFields;
private readonly transformer: TransformCompositeFields;

constructor(fieldNodeTransformerMap: FieldNodeMappers) {
this.transformer = new TransformObjectFields(
this.transformer = new TransformCompositeFields(
(_typeName, _fieldName, fieldConfig) => fieldConfig,
(typeName, fieldName, fieldNode, fragments) => {
const typeTransformers = fieldNodeTransformerMap[typeName];
Expand Down

0 comments on commit 5d8aad8

Please sign in to comment.