All Downloads are FREE. Search and download functionalities are using the official Maven repository.

node_modules.apollo-codegen.lib.compiler.visitors.collectFragmentsReferenced.js Maven / Gradle / Ivy

There is a newer version: 3.3.1
Show newest version
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function collectFragmentsReferenced(selectionSet, fragments, fragmentsReferenced = new Set()) {
    for (const selection of selectionSet.selections) {
        switch (selection.kind) {
            case 'FragmentSpread':
                fragmentsReferenced.add(selection.fragmentName);
                const fragment = fragments[selection.fragmentName];
                if (!fragment) {
                    throw new Error(`Cannot find fragment "${selection.fragmentName}"`);
                }
                collectFragmentsReferenced(fragment.selectionSet, fragments, fragmentsReferenced);
                break;
            case 'Field':
            case 'TypeCondition':
            case 'BooleanCondition':
                if (selection.selectionSet) {
                    collectFragmentsReferenced(selection.selectionSet, fragments, fragmentsReferenced);
                }
                break;
        }
    }
    return fragmentsReferenced;
}
exports.collectFragmentsReferenced = collectFragmentsReferenced;
//# sourceMappingURL=collectFragmentsReferenced.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy