@apollo/query-planner
Advanced tools
Comparing version 2.2.2 to 2.3.0-alpha.0
@@ -1,3 +0,2 @@ | ||
import { Operation, Schema, Concrete } from "@apollo/federation-internals"; | ||
import { QueryGraph } from "@apollo/query-graphs"; | ||
import { Operation, Schema } from "@apollo/federation-internals"; | ||
import { QueryPlannerConfig } from "./config"; | ||
@@ -9,11 +8,15 @@ import { QueryPlan } from "./QueryPlan"; | ||
}; | ||
export declare function computeQueryPlan({ config, supergraphSchema, federatedQueryGraph, operation, }: { | ||
config: Concrete<QueryPlannerConfig>; | ||
supergraphSchema: Schema; | ||
federatedQueryGraph: QueryGraph; | ||
operation: Operation; | ||
}): { | ||
plan: QueryPlan; | ||
statistics: PlanningStatistics; | ||
}; | ||
export declare class QueryPlanner { | ||
readonly supergraphSchema: Schema; | ||
private readonly config; | ||
private readonly federatedQueryGraph; | ||
private _lastGeneratedPlanStatistics; | ||
private readonly interfaceTypesWithInterfaceObjects; | ||
constructor(supergraphSchema: Schema, config?: QueryPlannerConfig); | ||
private collectInterfaceTypesWithInterfaceObjects; | ||
buildQueryPlan(operation: Operation): QueryPlan; | ||
private optimizeSiblingTypenames; | ||
private withSiblingTypenameOptimizedAway; | ||
lastGeneratedPlanStatistics(): PlanningStatistics | undefined; | ||
} | ||
//# sourceMappingURL=buildPlan.d.ts.map |
export { queryPlanSerializer, astSerializer } from './snapshotSerializers'; | ||
export { prettyFormatQueryPlan } from './prettyFormatQueryPlan'; | ||
export * from './QueryPlan'; | ||
import { QueryPlan } from './QueryPlan'; | ||
import { Schema, Operation } from '@apollo/federation-internals'; | ||
import { PlanningStatistics } from './buildPlan'; | ||
import { QueryPlannerConfig } from './config'; | ||
export { QueryPlanner } from './buildPlan'; | ||
export { QueryPlannerConfig } from './config'; | ||
export declare class QueryPlanner { | ||
readonly supergraphSchema: Schema; | ||
private readonly config; | ||
private readonly federatedQueryGraph; | ||
private _lastGeneratedPlanStatistics; | ||
constructor(supergraphSchema: Schema, config?: QueryPlannerConfig); | ||
buildQueryPlan(operation: Operation): QueryPlan; | ||
lastGeneratedPlanStatistics(): PlanningStatistics | undefined; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
@@ -24,29 +24,4 @@ "use strict"; | ||
__exportStar(require("./QueryPlan"), exports); | ||
const query_graphs_1 = require("@apollo/query-graphs"); | ||
const buildPlan_1 = require("./buildPlan"); | ||
const config_1 = require("./config"); | ||
class QueryPlanner { | ||
constructor(supergraphSchema, config) { | ||
this.supergraphSchema = supergraphSchema; | ||
this.config = (0, config_1.enforceQueryPlannerConfigDefaults)(config); | ||
this.federatedQueryGraph = (0, query_graphs_1.buildFederatedQueryGraph)(supergraphSchema, true); | ||
} | ||
buildQueryPlan(operation) { | ||
if (operation.selectionSet.isEmpty()) { | ||
return { kind: 'QueryPlan' }; | ||
} | ||
const { plan, statistics } = (0, buildPlan_1.computeQueryPlan)({ | ||
config: this.config, | ||
supergraphSchema: this.supergraphSchema, | ||
federatedQueryGraph: this.federatedQueryGraph, | ||
operation, | ||
}); | ||
this._lastGeneratedPlanStatistics = statistics; | ||
return plan; | ||
} | ||
lastGeneratedPlanStatistics() { | ||
return this._lastGeneratedPlanStatistics; | ||
} | ||
} | ||
exports.QueryPlanner = QueryPlanner; | ||
var buildPlan_1 = require("./buildPlan"); | ||
Object.defineProperty(exports, "QueryPlanner", { enumerable: true, get: function () { return buildPlan_1.QueryPlanner; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -27,3 +27,17 @@ import { SelectionNode as GraphQLJSSelectionNode, OperationTypeNode, DocumentNode } from 'graphql'; | ||
operationDocumentNode?: DocumentNode; | ||
inputRewrites?: FetchDataInputRewrite[]; | ||
outputRewrites?: FetchDataOutputRewrite[]; | ||
} | ||
export declare type FetchDataInputRewrite = FetchDataValueSetter; | ||
export declare type FetchDataOutputRewrite = FetchDataKeyRenamer; | ||
export interface FetchDataValueSetter { | ||
kind: 'ValueSetter'; | ||
path: string[]; | ||
setValueTo: any; | ||
} | ||
export interface FetchDataKeyRenamer { | ||
kind: 'KeyRenamer'; | ||
path: string[]; | ||
renameKeyTo: string; | ||
} | ||
export interface FlattenNode { | ||
@@ -30,0 +44,0 @@ kind: 'Flatten'; |
{ | ||
"name": "@apollo/query-planner", | ||
"version": "2.2.2", | ||
"version": "2.3.0-alpha.0", | ||
"description": "Apollo Query Planner", | ||
@@ -28,4 +28,4 @@ "author": "Apollo <packages@apollographql.com>", | ||
"dependencies": { | ||
"@apollo/federation-internals": "^2.2.2", | ||
"@apollo/query-graphs": "^2.2.2", | ||
"@apollo/federation-internals": "^2.3.0-alpha.0", | ||
"@apollo/query-graphs": "^2.3.0-alpha.0", | ||
"chalk": "^4.1.0", | ||
@@ -38,3 +38,3 @@ "deep-equal": "^2.0.5", | ||
}, | ||
"gitHead": "33f401239ce457c2dd840f38e9c3aa9795cc1c14" | ||
"gitHead": "b723008e72e58277bb366eb176b9f06e1949eff8" | ||
} |
@@ -5,42 +5,4 @@ export { queryPlanSerializer, astSerializer } from './snapshotSerializers'; | ||
export * from './QueryPlan'; | ||
import { QueryPlan } from './QueryPlan'; | ||
import { Schema, Operation, Concrete } from '@apollo/federation-internals'; | ||
import { buildFederatedQueryGraph, QueryGraph } from "@apollo/query-graphs"; | ||
import { computeQueryPlan, PlanningStatistics } from './buildPlan'; | ||
import { enforceQueryPlannerConfigDefaults, QueryPlannerConfig } from './config'; | ||
export { QueryPlanner } from './buildPlan'; | ||
export { QueryPlannerConfig } from './config'; | ||
export class QueryPlanner { | ||
private readonly config: Concrete<QueryPlannerConfig>; | ||
private readonly federatedQueryGraph: QueryGraph; | ||
private _lastGeneratedPlanStatistics: PlanningStatistics | undefined; | ||
constructor( | ||
public readonly supergraphSchema: Schema, | ||
config?: QueryPlannerConfig | ||
) { | ||
this.config = enforceQueryPlannerConfigDefaults(config); | ||
this.federatedQueryGraph = buildFederatedQueryGraph(supergraphSchema, true); | ||
} | ||
buildQueryPlan(operation: Operation): QueryPlan { | ||
if (operation.selectionSet.isEmpty()) { | ||
return { kind: 'QueryPlan' }; | ||
} | ||
const {plan, statistics} = computeQueryPlan({ | ||
config: this.config, | ||
supergraphSchema: this.supergraphSchema, | ||
federatedQueryGraph: this.federatedQueryGraph, | ||
operation, | ||
}); | ||
this._lastGeneratedPlanStatistics = statistics; | ||
return plan; | ||
} | ||
lastGeneratedPlanStatistics(): PlanningStatistics | undefined { | ||
return this._lastGeneratedPlanStatistics; | ||
} | ||
} |
@@ -42,4 +42,50 @@ import { | ||
operationDocumentNode?: DocumentNode; | ||
// Optionally describe a number of "rewrites" that query plan executors should apply to the data that is sent as input of this fetch. | ||
inputRewrites?: FetchDataInputRewrite[]; | ||
// Similar, but for optional "rewrites" to apply to the data that received from a fetch (and before it is apply to the current in-memory results). | ||
outputRewrites?: FetchDataOutputRewrite[]; | ||
} | ||
/** | ||
* The type of rewrites currently supported on the input data of fetches. | ||
* | ||
* A rewrite usually identifies some subpart of the input data and some action to perform on that subpart. | ||
* Note that input rewrites should only impact the inputs of the fetch they are applied to (meaning that, as | ||
* those inputs are collected from the current in-memory result, the rewrite should _not_ impact said in-memory | ||
* results, only what is sent in the fetch). | ||
*/ | ||
export type FetchDataInputRewrite = FetchDataValueSetter; | ||
/** | ||
* The type of rewrites currently supported on the output data of fetches. | ||
* | ||
* A rewrite usually identifies some subpart of the ouput data and some action to perform on that subpart. | ||
* Note that ouput rewrites should only impact the outputs of the fetch they are applied to (meaning that | ||
* the rewrites must be applied before the data from the fetch is merged to the current in-memory result). | ||
*/ | ||
export type FetchDataOutputRewrite = FetchDataKeyRenamer; | ||
/** | ||
* A rewrite that sets a value at the provided path of the data it is applied to. | ||
*/ | ||
export interface FetchDataValueSetter { | ||
kind: 'ValueSetter', | ||
// Path to the key that is set by this "rewrite". It is of the form `[ 'x', '... on A', 'y' ]`, where fragments | ||
// means that the path should only match for objects whose `__typename` is he provided type. | ||
// If the path does not match in the data this is applied to, then this setter should not rewrite the data. | ||
// The path starts at the top of the data it is applied to. So for instance, for fetch data inputs, the path | ||
// start at the root of the object representing those inputs. | ||
path: string[], | ||
// The value to set at `path`. | ||
setValueTo: any, | ||
} | ||
export interface FetchDataKeyRenamer { | ||
kind: 'KeyRenamer' | ||
// Same format as in `FetchDataValueSetter`, but this renames the key at the very end of this path to the | ||
// name from `renameKeyTo`. | ||
path: string[], | ||
renameKeyTo: string, | ||
} | ||
export interface FlattenNode { | ||
@@ -46,0 +92,0 @@ kind: 'Flatten'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
855831
103
16731
2