@apollo/query-planner
Advanced tools
Comparing version 2.0.0-preview.0 to 2.0.0-preview.1
@@ -5,9 +5,11 @@ export { queryPlanSerializer, astSerializer } from './snapshotSerializers'; | ||
import { QueryPlan } from './QueryPlan'; | ||
import { Schema, Operation } from '@apollo/federation-internals'; | ||
export * from './composedSchema'; | ||
import { BuildQueryPlanOptions, buildOperationContext, OperationContext } from './buildQueryPlan'; | ||
import { GraphQLSchema } from 'graphql'; | ||
export { BuildQueryPlanOptions, buildOperationContext }; | ||
export declare class QueryPlanner { | ||
readonly supergraphSchema: Schema; | ||
private readonly federatedQueryGraph; | ||
constructor(supergraphSchema: Schema); | ||
buildQueryPlan(operation: Operation): QueryPlan; | ||
readonly schema: GraphQLSchema; | ||
constructor(schema: GraphQLSchema); | ||
buildQueryPlan(operationContext: OperationContext, options?: BuildQueryPlanOptions): QueryPlan; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.QueryPlanner = exports.prettyFormatQueryPlan = exports.astSerializer = exports.queryPlanSerializer = void 0; | ||
exports.QueryPlanner = exports.buildOperationContext = exports.prettyFormatQueryPlan = exports.astSerializer = exports.queryPlanSerializer = void 0; | ||
var snapshotSerializers_1 = require("./snapshotSerializers"); | ||
@@ -25,14 +25,11 @@ Object.defineProperty(exports, "queryPlanSerializer", { enumerable: true, get: function () { return snapshotSerializers_1.queryPlanSerializer; } }); | ||
__exportStar(require("./QueryPlan"), exports); | ||
const query_graphs_1 = require("@apollo/query-graphs"); | ||
const buildPlan_1 = require("./buildPlan"); | ||
__exportStar(require("./composedSchema"), exports); | ||
const buildQueryPlan_1 = require("./buildQueryPlan"); | ||
Object.defineProperty(exports, "buildOperationContext", { enumerable: true, get: function () { return buildQueryPlan_1.buildOperationContext; } }); | ||
class QueryPlanner { | ||
constructor(supergraphSchema) { | ||
this.supergraphSchema = supergraphSchema; | ||
this.federatedQueryGraph = (0, query_graphs_1.buildFederatedQueryGraph)(supergraphSchema, true); | ||
constructor(schema) { | ||
this.schema = schema; | ||
} | ||
buildQueryPlan(operation) { | ||
if (operation.selectionSet.isEmpty()) { | ||
return { kind: 'QueryPlan' }; | ||
} | ||
return (0, buildPlan_1.computeQueryPlan)(this.supergraphSchema, this.federatedQueryGraph, operation); | ||
buildQueryPlan(operationContext, options) { | ||
return (0, buildQueryPlan_1.buildQueryPlan)({ ...operationContext, schema: this.schema }, options); | ||
} | ||
@@ -39,0 +36,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { SelectionNode as GraphQLJSSelectionNode, OperationTypeNode } from 'graphql'; | ||
import { SelectionNode as GraphQLJSSelectionNode } from 'graphql'; | ||
export declare type ResponsePath = (string | number)[]; | ||
@@ -22,4 +22,6 @@ export interface QueryPlan { | ||
operation: string; | ||
operationName: string | undefined; | ||
operationKind: OperationTypeNode; | ||
inclusionConditions?: { | ||
skip: string | boolean | null; | ||
include: string | boolean | null; | ||
}[]; | ||
} | ||
@@ -26,0 +28,0 @@ export interface FlattenNode { |
@@ -29,2 +29,3 @@ "use strict"; | ||
} | ||
; | ||
function remapInlineFragmentNodes(node) { | ||
@@ -31,0 +32,0 @@ return (0, graphql_1.visit)(node, { |
@@ -20,3 +20,3 @@ "use strict"; | ||
result += | ||
`Fetch(service: "${node.serviceName}")` + | ||
`Fetch(service: "${node.serviceName}"${printInclusionConditions(node)})` + | ||
' {' + | ||
@@ -47,2 +47,15 @@ config.spacingOuter + | ||
} | ||
function printInclusionConditions(node) { | ||
return node.inclusionConditions | ||
? `, inclusionConditions: [${node.inclusionConditions | ||
.map((e) => { | ||
return `{ ${e.include !== null | ||
? `include: ${typeof e.include === 'string' ? `"${e.include}"` : e.include}` | ||
: ''}${e.include !== null && e.skip !== null ? ', ' : ''}${e.skip !== null | ||
? `skip: ${typeof e.skip === 'string' ? `"${e.skip}"` : e.skip}` | ||
: ''} }`; | ||
}) | ||
.join(', ')}]` | ||
: ''; | ||
} | ||
function printNodes(nodes, config, indentation, depth, refs, printer) { | ||
@@ -49,0 +62,0 @@ let result = ''; |
@@ -29,3 +29,3 @@ "use strict"; | ||
return [undefined, array]; | ||
const remaining = array.slice(0, index); | ||
let remaining = array.slice(0, index); | ||
if (index < array.length - 1) { | ||
@@ -32,0 +32,0 @@ remaining.push(...array.slice(index + 1)); |
{ | ||
"name": "@apollo/query-planner", | ||
"version": "2.0.0-preview.0", | ||
"version": "2.0.0-preview.1", | ||
"description": "Apollo Query Planner", | ||
@@ -28,4 +28,4 @@ "author": "Apollo <packages@apollographql.com>", | ||
"dependencies": { | ||
"@apollo/federation-internals": "^2.0.0-preview.0", | ||
"@apollo/query-graphs": "^2.0.0-preview.0", | ||
"@apollo/federation-internals": "^2.0.0-preview.1", | ||
"@apollo/query-graphs": "^2.0.0-preview.1", | ||
"chalk": "^4.1.0", | ||
@@ -38,3 +38,3 @@ "deep-equal": "^2.0.5", | ||
}, | ||
"gitHead": "e76fd3e16bf140ba9b30fe26d48657bccca180dc" | ||
"gitHead": "0ab9894af98cc2687fe261ce415f19df0380a399" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
578710
147
7177
1