UNPKG

34.1 kBSource Map (JSON)View Raw
1{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/utilities/graphql/transform.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAWL,KAAK,EAEL,IAAI,GAGL,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,iBAAiB,GAElB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAyB3C,IAAM,cAAc,GAAc;IAChC,IAAI,EAAE,IAAI,CAAC,KAAK;IAChB,IAAI,EAAE;QACJ,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,YAAY;KACpB;CACF,CAAC;AAEF,SAAS,OAAO,CACd,EAAoD,EACpD,WAAwB;IAExB,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAC5C,UAAA,SAAS,IAAI,OAAA,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC,eAAe;QAClD,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,EAD5C,CAC4C,CAC1D,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAiB;IACzC,OAAO,OAAO,CACZ,sBAAsB,CAAC,GAAG,CAAC,IAAI,qBAAqB,CAAC,GAAG,CAAC,EACzD,iBAAiB,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAC/C;QACC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,GAAG,CAAC;AACV,CAAC;AAED,SAAS,mBAAmB,CAC1B,UAA0D;IAE1D,IAAM,OAAO,GAAG,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AExB,IAAI,WAAW,GAAG,4BAA4B,CAC5C;QACE;YACE,IAAI,EAAE,UAAC,SAAwB,IAAK,OAAA,SAAS,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAjC,CAAiC;YACrE,MAAM,EAAE,IAAI;SACb;KACF,EACD,QAAQ,CACT,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { invariant } from '../globals';\n\nimport {\n DocumentNode,\n SelectionNode,\n SelectionSetNode,\n OperationDefinitionNode,\n FieldNode,\n DirectiveNode,\n FragmentDefinitionNode,\n ArgumentNode,\n FragmentSpreadNode,\n VariableDefinitionNode,\n visit,\n ASTNode,\n Kind,\n ASTVisitor,\n InlineFragmentNode,\n} from 'graphql';\n\nimport {\n checkDocument,\n getOperationDefinition,\n getFragmentDefinition,\n getFragmentDefinitions,\n getMainDefinition,\n} from './getFromAST';\nimport { isField } from './storeUtils';\nimport {\n createFragmentMap,\n FragmentMap,\n} from './fragments';\nimport { isArray } from '../common/arrays';\n\nexport type RemoveNodeConfig<N> = {\n name?: string;\n test?: (node: N) => boolean;\n remove?: boolean;\n};\n\nexport type GetNodeConfig<N> = {\n name?: string;\n test?: (node: N) => boolean;\n};\n\nexport type RemoveDirectiveConfig = RemoveNodeConfig<DirectiveNode>;\nexport type GetDirectiveConfig = GetNodeConfig<DirectiveNode>;\nexport type RemoveArgumentsConfig = RemoveNodeConfig<ArgumentNode>;\nexport type GetFragmentSpreadConfig = GetNodeConfig<FragmentSpreadNode>;\nexport type RemoveFragmentSpreadConfig = RemoveNodeConfig<FragmentSpreadNode>;\nexport type RemoveFragmentDefinitionConfig = RemoveNodeConfig<\n FragmentDefinitionNode\n>;\nexport type RemoveVariableDefinitionConfig = RemoveNodeConfig<\n VariableDefinitionNode\n>;\n\nconst TYPENAME_FIELD: FieldNode = {\n kind: Kind.FIELD,\n name: {\n kind: Kind.NAME,\n value: '__typename',\n },\n};\n\nfunction isEmpty(\n op: OperationDefinitionNode | FragmentDefinitionNode,\n fragmentMap: FragmentMap,\n): boolean {\n return !op || op.selectionSet.selections.every(\n selection => selection.kind === Kind.FRAGMENT_SPREAD &&\n isEmpty(fragmentMap[selection.name.value], fragmentMap)\n );\n}\n\nfunction nullIfDocIsEmpty(doc: DocumentNode) {\n return isEmpty(\n getOperationDefinition(doc) || getFragmentDefinition(doc),\n createFragmentMap(getFragmentDefinitions(doc)),\n )\n ? null\n : doc;\n}\n\nfunction getDirectiveMatcher(\n directives: (RemoveDirectiveConfig | GetDirectiveConfig)[],\n) {\n const nameSet = new Set<string>();\n const tests: Array<(directive: DirectiveNode) => boolean> = [];\n directives.forEach(directive => {\n if (directive.name) {\n nameSet.add(directive.name);\n } else if (directive.test) {\n tests.push(directive.test);\n }\n });\n\n return (directive: DirectiveNode) => (\n nameSet.has(directive.name.value) ||\n tests.some(test => test(directive))\n );\n}\n\n// Helper interface and function used by removeDirectivesFromDocument to keep\n// track of variable references and fragments spreads found within a given\n// operation or fragment definition.\ninterface InternalInUseInfo {\n variables: Set<string>;\n fragmentSpreads: Set<string>;\n // Set to true when we deliberately remove a fragment definition, so we can\n // make sure also to remove dangling ...spreads that refer to it.\n removed?: boolean;\n // Populated by the populateTransitiveVars helper function below.\n transitiveVars?: Set<string>;\n}\nfunction makeInUseGetterFunction<TKey>(defaultKey: TKey) {\n const map = new Map<TKey, InternalInUseInfo>();\n\n return function inUseGetterFunction(\n key: TKey = defaultKey\n ): InternalInUseInfo {\n let inUse = map.get(key);\n if (!inUse) {\n map.set(key, inUse = {\n // Variable and fragment spread names used directly within this\n // operation or fragment definition, as identified by key. These sets\n // will be populated during the first traversal of the document in\n // removeDirectivesFromDocument below.\n variables: new Set,\n fragmentSpreads: new Set,\n });\n }\n return inUse;\n };\n}\n\nexport function removeDirectivesFromDocument(\n directives: RemoveDirectiveConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n // Passing empty strings to makeInUseGetterFunction means we handle anonymous\n // operations as if their names were \"\". Anonymous fragment definitions are\n // not supposed to be possible, but the same default naming strategy seems\n // appropriate for that case as well.\n const getInUseByOperationName = makeInUseGetterFunction<string>(\"\");\n const getInUseByFragmentName = makeInUseGetterFunction<string>(\"\");\n const getInUse = (\n ancestors: readonly (ASTNode | readonly ASTNode[])[],\n ): InternalInUseInfo | null => {\n for (\n let p = 0, ancestor: ASTNode | readonly ASTNode[];\n p < ancestors.length && (ancestor = ancestors[p]);\n ++p\n ) {\n if (isArray(ancestor)) continue;\n if (ancestor.kind === Kind.OPERATION_DEFINITION) {\n // If an operation is anonymous, we use the empty string as its key.\n return getInUseByOperationName(ancestor.name && ancestor.name.value);\n }\n if (ancestor.kind === Kind.FRAGMENT_DEFINITION) {\n return getInUseByFragmentName(ancestor.name.value);\n }\n }\n invariant.error(`Could not find operation or fragment`);\n return null;\n };\n\n let operationCount = 0;\n for (let i = doc.definitions.length - 1; i >= 0; --i) {\n if (doc.definitions[i].kind === Kind.OPERATION_DEFINITION) {\n ++operationCount;\n }\n }\n\n const directiveMatcher = getDirectiveMatcher(directives);\n const hasRemoveDirective = directives.some(directive => directive.remove);\n const shouldRemoveField = (\n nodeDirectives: FieldNode[\"directives\"]\n ) => (\n hasRemoveDirective &&\n nodeDirectives &&\n nodeDirectives.some(directiveMatcher)\n );\n\n const originalFragmentDefsByPath = new Map<string, FragmentDefinitionNode>();\n\n // Any time the first traversal of the document below makes a change like\n // removing a fragment (by returning null), this variable should be set to\n // true. Once it becomes true, it should never be set to false again. If this\n // variable remains false throughout the traversal, then we can return the\n // original doc immediately without any modifications.\n let firstVisitMadeChanges = false;\n\n const fieldOrInlineFragmentVisitor: ASTVisitor = {\n enter(node: FieldNode | InlineFragmentNode) {\n if (shouldRemoveField(node.directives)) {\n firstVisitMadeChanges = true;\n return null;\n }\n },\n };\n\n const docWithoutDirectiveSubtrees = visit(doc, {\n // These two AST node types share the same implementation, defined above.\n Field: fieldOrInlineFragmentVisitor,\n InlineFragment: fieldOrInlineFragmentVisitor,\n\n VariableDefinition: {\n enter() {\n // VariableDefinition nodes do not count as variables in use, though\n // they do contain Variable nodes that might be visited below. To avoid\n // counting variable declarations as usages, we skip visiting the\n // contents of this VariableDefinition node by returning false.\n return false;\n },\n },\n\n Variable: {\n enter(node, _key, _parent, _path, ancestors) {\n const inUse = getInUse(ancestors);\n if (inUse) {\n inUse.variables.add(node.name.value);\n }\n },\n },\n\n FragmentSpread: {\n enter(node, _key, _parent, _path, ancestors) {\n if (shouldRemoveField(node.directives)) {\n firstVisitMadeChanges = true;\n return null;\n }\n const inUse = getInUse(ancestors);\n if (inUse) {\n inUse.fragmentSpreads.add(node.name.value);\n }\n // We might like to remove this FragmentSpread by returning null here if\n // the corresponding FragmentDefinition node is also going to be removed\n // by the logic below, but we can't control the relative order of those\n // events, so we have to postpone the removal of dangling FragmentSpread\n // nodes until after the current visit of the document has finished.\n },\n },\n\n FragmentDefinition: {\n enter(node, _key, _parent, path) {\n originalFragmentDefsByPath.set(JSON.stringify(path), node);\n },\n leave(node, _key, _parent, path) {\n const originalNode = originalFragmentDefsByPath.get(JSON.stringify(path));\n if (node === originalNode) {\n // If the FragmentNode received by this leave function is identical to\n // the one received by the corresponding enter function (above), then\n // the visitor must not have made any changes within this\n // FragmentDefinition node. This fragment definition may still be\n // removed if there are no ...spread references to it, but it won't be\n // removed just because it has only a __typename field.\n return node;\n }\n\n if (\n // This logic applies only if the document contains one or more\n // operations, since removing all fragments from a document containing\n // only fragments makes the document useless.\n operationCount > 0 &&\n node.selectionSet.selections.every(selection => (\n selection.kind === Kind.FIELD &&\n selection.name.value === '__typename'\n ))\n ) {\n // This is a somewhat opinionated choice: if a FragmentDefinition ends\n // up having no fields other than __typename, we remove the whole\n // fragment definition, and later prune ...spread references to it.\n getInUseByFragmentName(node.name.value).removed = true;\n firstVisitMadeChanges = true;\n return null;\n }\n },\n },\n\n Directive: {\n leave(node) {\n // If a matching directive is found, remove the directive itself. Note\n // that this does not remove the target (field, argument, etc) of the\n // directive, but only the directive itself.\n if (directiveMatcher(node)) {\n firstVisitMadeChanges = true;\n return null;\n }\n },\n },\n });\n\n if (!firstVisitMadeChanges) {\n // If our first pass did not change anything about the document, then there\n // is no cleanup we need to do, and we can return the original doc.\n return doc;\n }\n\n // Utility for making sure inUse.transitiveVars is recursively populated.\n // Because this logic assumes inUse.fragmentSpreads has been completely\n // populated and inUse.removed has been set if appropriate,\n // populateTransitiveVars must be called after that information has been\n // collected by the first traversal of the document.\n const populateTransitiveVars = (\n inUse: InternalInUseInfo,\n ) => {\n if (!inUse.transitiveVars) {\n inUse.transitiveVars = new Set(inUse.variables);\n if (!inUse.removed) {\n inUse.fragmentSpreads.forEach(childFragmentName => {\n populateTransitiveVars(\n getInUseByFragmentName(childFragmentName)\n ).transitiveVars!.forEach(varName => {\n inUse.transitiveVars!.add(varName);\n });\n });\n }\n }\n return inUse;\n };\n\n // Since we've been keeping track of fragment spreads used by particular\n // operations and fragment definitions, we now need to compute the set of all\n // spreads used (transitively) by any operations in the document.\n const allFragmentNamesUsed = new Set<string>();\n docWithoutDirectiveSubtrees.definitions.forEach(def => {\n if (def.kind === Kind.OPERATION_DEFINITION) {\n populateTransitiveVars(\n getInUseByOperationName(def.name && def.name.value)\n ).fragmentSpreads.forEach(childFragmentName => {\n allFragmentNamesUsed.add(childFragmentName);\n });\n } else if (\n def.kind === Kind.FRAGMENT_DEFINITION &&\n // If there are no operations in the document, then all fragment\n // definitions count as usages of their own fragment names. This heuristic\n // prevents accidentally removing all fragment definitions from the\n // document just because it contains no operations that use the fragments.\n operationCount === 0 &&\n !getInUseByFragmentName(def.name.value).removed\n ) {\n allFragmentNamesUsed.add(def.name.value);\n }\n });\n // Now that we have added all fragment spreads used by operations to the\n // allFragmentNamesUsed set, we can complete the set by transitively adding\n // all fragment spreads used by those fragments, and so on.\n allFragmentNamesUsed.forEach(fragmentName => {\n // Once all the childFragmentName strings added here have been seen already,\n // the top-level allFragmentNamesUsed.forEach loop will terminate.\n populateTransitiveVars(\n getInUseByFragmentName(fragmentName)\n ).fragmentSpreads.forEach(childFragmentName => {\n allFragmentNamesUsed.add(childFragmentName);\n });\n });\n\n const fragmentWillBeRemoved = (\n fragmentName: string,\n ) => !!(\n // A fragment definition will be removed if there are no spreads that refer\n // to it, or the fragment was explicitly removed because it had no fields\n // other than __typename.\n !allFragmentNamesUsed.has(fragmentName) ||\n getInUseByFragmentName(fragmentName).removed\n );\n\n const enterVisitor: ASTVisitor = {\n enter(node: FragmentSpreadNode | FragmentDefinitionNode) {\n if (fragmentWillBeRemoved(node.name.value)) {\n return null;\n }\n },\n };\n\n return nullIfDocIsEmpty(visit(docWithoutDirectiveSubtrees, {\n // If the fragment is going to be removed, then leaving any dangling\n // FragmentSpread nodes with the same name would be a mistake.\n FragmentSpread: enterVisitor,\n\n // This is where the fragment definition is actually removed.\n FragmentDefinition: enterVisitor,\n\n OperationDefinition: {\n leave(node) {\n // Upon leaving each operation in the depth-first AST traversal, prune\n // any variables that are declared by the operation but unused within.\n if (node.variableDefinitions) {\n const usedVariableNames = populateTransitiveVars(\n // If an operation is anonymous, we use the empty string as its key.\n getInUseByOperationName(node.name && node.name.value)\n ).transitiveVars!;\n\n // According to the GraphQL spec, all variables declared by an\n // operation must either be used by that operation or used by some\n // fragment included transitively into that operation:\n // https://spec.graphql.org/draft/#sec-All-Variables-Used\n //\n // To stay on the right side of this validation rule, if/when we\n // remove the last $var references from an operation or its fragments,\n // we must also remove the corresponding $var declaration from the\n // enclosing operation. This pruning applies only to operations and\n // not fragment definitions, at the moment. Fragments may be able to\n // declare variables eventually, but today they can only consume them.\n if (usedVariableNames.size < node.variableDefinitions.length) {\n return {\n ...node,\n variableDefinitions: node.variableDefinitions.filter(\n varDef => usedVariableNames.has(varDef.variable.name.value),\n ),\n };\n }\n }\n },\n },\n }));\n}\n\nexport const addTypenameToDocument = Object.assign(function <\n TNode extends ASTNode\n>(\n doc: TNode\n): TNode {\n return visit(doc, {\n SelectionSet: {\n enter(node, _key, parent) {\n // Don't add __typename to OperationDefinitions.\n if (\n parent &&\n (parent as OperationDefinitionNode).kind === Kind.OPERATION_DEFINITION\n ) {\n return;\n }\n\n // No changes if no selections.\n const { selections } = node;\n if (!selections) {\n return;\n }\n\n // If selections already have a __typename, or are part of an\n // introspection query, do nothing.\n const skip = selections.some(selection => {\n return (\n isField(selection) &&\n (selection.name.value === '__typename' ||\n selection.name.value.lastIndexOf('__', 0) === 0)\n );\n });\n if (skip) {\n return;\n }\n\n // If this SelectionSet is @export-ed as an input variable, it should\n // not have a __typename field (see issue #4691).\n const field = parent as FieldNode;\n if (\n isField(field) &&\n field.directives &&\n field.directives.some(d => d.name.value === 'export')\n ) {\n return;\n }\n\n // Create and return a new SelectionSet with a __typename Field.\n return {\n ...node,\n selections: [...selections, TYPENAME_FIELD],\n };\n },\n },\n });\n}, {\n added(field: FieldNode): boolean {\n return field === TYPENAME_FIELD;\n },\n});\n\nconst connectionRemoveConfig = {\n test: (directive: DirectiveNode) => {\n const willRemove = directive.name.value === 'connection';\n if (willRemove) {\n if (\n !directive.arguments ||\n !directive.arguments.some(arg => arg.name.value === 'key')\n ) {\n invariant.warn(\n 'Removing an @connection directive even though it does not have a key. ' +\n 'You may want to use the key parameter to specify a store key.',\n );\n }\n }\n\n return willRemove;\n },\n};\n\nexport function removeConnectionDirectiveFromDocument(doc: DocumentNode) {\n return removeDirectivesFromDocument(\n [connectionRemoveConfig],\n checkDocument(doc),\n );\n}\n\nfunction hasDirectivesInSelectionSet(\n directives: GetDirectiveConfig[],\n selectionSet: SelectionSetNode | undefined,\n nestedCheck = true,\n): boolean {\n return (\n !!selectionSet &&\n selectionSet.selections &&\n selectionSet.selections.some(selection =>\n hasDirectivesInSelection(directives, selection, nestedCheck),\n )\n );\n}\n\nfunction hasDirectivesInSelection(\n directives: GetDirectiveConfig[],\n selection: SelectionNode,\n nestedCheck = true,\n): boolean {\n if (!isField(selection)) {\n return true;\n }\n\n if (!selection.directives) {\n return false;\n }\n\n return (\n selection.directives.some(getDirectiveMatcher(directives)) ||\n (nestedCheck &&\n hasDirectivesInSelectionSet(\n directives,\n selection.selectionSet,\n nestedCheck,\n ))\n );\n}\n\nfunction getArgumentMatcher(config: RemoveArgumentsConfig[]) {\n return function argumentMatcher(argument: ArgumentNode) {\n return config.some(\n (aConfig: RemoveArgumentsConfig) =>\n argument.value &&\n argument.value.kind === Kind.VARIABLE &&\n argument.value.name &&\n (aConfig.name === argument.value.name.value ||\n (aConfig.test && aConfig.test(argument))),\n );\n };\n}\n\nexport function removeArgumentsFromDocument(\n config: RemoveArgumentsConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n const argMatcher = getArgumentMatcher(config);\n\n return nullIfDocIsEmpty(\n visit(doc, {\n OperationDefinition: {\n enter(node) {\n return {\n ...node,\n // Remove matching top level variables definitions.\n variableDefinitions: node.variableDefinitions ? node.variableDefinitions.filter(\n varDef =>\n !config.some(arg => arg.name === varDef.variable.name.value),\n ) : [],\n };\n },\n },\n\n Field: {\n enter(node) {\n // If `remove` is set to true for an argument, and an argument match\n // is found for a field, remove the field as well.\n const shouldRemoveField = config.some(argConfig => argConfig.remove);\n\n if (shouldRemoveField) {\n let argMatchCount = 0;\n if (node.arguments) {\n node.arguments.forEach(arg => {\n if (argMatcher(arg)) {\n argMatchCount += 1;\n }\n });\n }\n\n if (argMatchCount === 1) {\n return null;\n }\n }\n },\n },\n\n Argument: {\n enter(node) {\n // Remove all matching arguments.\n if (argMatcher(node)) {\n return null;\n }\n },\n },\n }),\n );\n}\n\nexport function removeFragmentSpreadFromDocument(\n config: RemoveFragmentSpreadConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n function enter(\n node: FragmentSpreadNode | FragmentDefinitionNode,\n ): null | void {\n if (config.some(def => def.name === node.name.value)) {\n return null;\n }\n }\n\n return nullIfDocIsEmpty(\n visit(doc, {\n FragmentSpread: { enter },\n FragmentDefinition: { enter },\n }),\n );\n}\n\n// If the incoming document is a query, return it as is. Otherwise, build a\n// new document containing a query operation based on the selection set\n// of the previous main operation.\nexport function buildQueryFromSelectionSet(\n document: DocumentNode,\n): DocumentNode {\n const definition = getMainDefinition(document);\n const definitionOperation = (<OperationDefinitionNode>definition).operation;\n\n if (definitionOperation === 'query') {\n // Already a query, so return the existing document.\n return document;\n }\n\n // Build a new query using the selection set of the main operation.\n const modifiedDoc = visit(document, {\n OperationDefinition: {\n enter(node) {\n return {\n ...node,\n operation: 'query',\n };\n },\n },\n });\n return modifiedDoc;\n}\n\n// Remove fields / selection sets that include an @client directive.\nexport function removeClientSetsFromDocument(\n document: DocumentNode,\n): DocumentNode | null {\n checkDocument(document);\n\n let modifiedDoc = removeDirectivesFromDocument(\n [\n {\n test: (directive: DirectiveNode) => directive.name.value === 'client',\n remove: true,\n },\n ],\n document,\n );\n\n return modifiedDoc;\n}\n"]}
\No newline at end of file