Files
30-seconds-of-code/node_modules/@gatsbyjs/relay-compiler/lib/GraphQLIRVisitor.js
2019-08-20 15:52:05 +02:00

42 lines
1.1 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use strict';
var visit = require("graphql").visit;
var NodeKeys = {
Argument: ['value'],
Condition: ['condition', 'selections'],
Defer: ['selections', 'if'],
Directive: ['args'],
Fragment: ['argumentDefinitions', 'directives', 'selections'],
FragmentSpread: ['args', 'directives'],
InlineFragment: ['directives', 'selections'],
LinkedField: ['args', 'directives', 'selections'],
Literal: [],
LocalArgumentDefinition: [],
MatchField: ['args', 'directives', 'selections'],
MatchBranch: ['selections'],
Request: ['fragment', 'root'],
Root: ['argumentDefinitions', 'directives', 'selections'],
RootArgumentDefinition: [],
ScalarField: ['args', 'directives'],
SplitOperation: ['selections'],
Stream: ['selections', 'if', 'initialCount'],
Variable: []
};
function visitIR(root, visitor) {
return visit(root, visitor, NodeKeys);
}
module.exports = {
visit: visitIR
};