From 30494c1c1a9dbf5129fef410001ad25325f08442 Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Fri, 3 Sep 2021 02:28:59 +0300 Subject: [PATCH] workaround for v16 --- packages/delegate/src/prepareGatewayDocument.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/delegate/src/prepareGatewayDocument.ts b/packages/delegate/src/prepareGatewayDocument.ts index 3601e3d55e5..974c1f4b731 100644 --- a/packages/delegate/src/prepareGatewayDocument.ts +++ b/packages/delegate/src/prepareGatewayDocument.ts @@ -411,6 +411,22 @@ function wrapConcreteTypes( } }, [Kind.FIELD]: (node: FieldNode) => { + // workaround for v16 lack of visitorKeys + // + // in v15, we never enter subfields because we don't visit any keys for nodes of kind `Kind.FIELD` + // which automatically means we only visit 'root fields', no matter how nested they are in fragment + // nodes. + // + // In v16, visitorKeys is gone, and we have to enter child fields and explicitly exit by returning + // 'false'. + const parentType = typeInfo.getParentType(); + if (parentType == null) { + return false; + } + if (!rootTypeNames.has(parentType.name)) { + return false; + } + // end-workaround const type = typeInfo.getType(); if (type != null && isAbstractType(getNamedType(type))) { return {