@apollo/federation-internals
Advanced tools
Comparing version 2.7.1 to 2.7.2
import { ConstArgumentNode, ASTNode, DirectiveLocation, ConstDirectiveNode, DocumentNode, GraphQLError, GraphQLSchema, Kind, TypeNode, VariableDefinitionNode, VariableNode, DirectiveDefinitionNode, DirectiveNode } from "graphql"; | ||
import { CoreImport, CoreSpecDefinition, FeatureUrl } from "./specs/coreSpec"; | ||
import { CoreImport, CoreSpecDefinition, FeatureUrl, FeatureVersion } from "./specs/coreSpec"; | ||
import { MapWithCachedArrays } from "./utils"; | ||
@@ -214,2 +214,3 @@ import { SDLValidationRule } from "graphql/validation/ValidationContext"; | ||
typeNameInSchema(name: string): string; | ||
minimumFederationVersion(): FeatureVersion | undefined; | ||
} | ||
@@ -216,0 +217,0 @@ export declare class CoreFeatures { |
@@ -108,5 +108,6 @@ import { CompositeType, CoreFeature, Directive, DirectiveDefinition, FieldDefinition, InputFieldDefinition, InterfaceType, NamedType, ObjectType, ScalarType, Schema, SchemaBlueprint, SchemaConfig, SchemaElement, UnionType } from "./definitions"; | ||
} | ||
export declare function setSchemaAsFed2Subgraph(schema: Schema): void; | ||
export declare function setSchemaAsFed2Subgraph(schema: Schema, useLatest?: boolean): void; | ||
export declare const FEDERATION2_LINK_WITH_FULL_IMPORTS = "@link(url: \"https://specs.apollo.dev/federation/v2.7\", import: [\"@key\", \"@requires\", \"@provides\", \"@external\", \"@tag\", \"@extends\", \"@shareable\", \"@inaccessible\", \"@override\", \"@composeDirective\", \"@interfaceObject\", \"@authenticated\", \"@requiresScopes\", \"@policy\", \"@sourceAPI\", \"@sourceType\", \"@sourceField\"])"; | ||
export declare const FEDERATION2_LINK_WITH_AUTO_EXPANDED_IMPORTS = "@link(url: \"https://specs.apollo.dev/federation/v2.7\", import: [\"@key\", \"@requires\", \"@provides\", \"@external\", \"@tag\", \"@extends\", \"@shareable\", \"@inaccessible\", \"@override\", \"@composeDirective\", \"@interfaceObject\"])"; | ||
export declare const FEDERATION2_LINK_WITH_AUTO_EXPANDED_IMPORTS_UPGRADED = "@link(url: \"https://specs.apollo.dev/federation/v2.4\", import: [\"@key\", \"@requires\", \"@provides\", \"@external\", \"@tag\", \"@extends\", \"@shareable\", \"@inaccessible\", \"@override\", \"@composeDirective\", \"@interfaceObject\"])"; | ||
export declare function asFed2SubgraphDocument(document: DocumentNode, options?: { | ||
@@ -113,0 +114,0 @@ addAsSchemaExtension?: boolean; |
@@ -110,2 +110,3 @@ import { ArgumentNode, DocumentNode, FieldNode, FragmentDefinitionNode, SelectionNode, SelectionSetNode } from "graphql"; | ||
optimize(fragments?: NamedFragments, minUsagesToOptimize?: number): Operation; | ||
generateQueryFragments(): Operation; | ||
expandAllFragments(): Operation; | ||
@@ -165,3 +166,2 @@ normalize(): Operation; | ||
mapToExpandedSelectionSets(mapper: (selectionSet: SelectionSet) => SelectionSet | undefined): NamedFragments | undefined; | ||
private selectionSetIsWorthUsing; | ||
rebaseOn(schema: Schema): NamedFragments | undefined; | ||
@@ -200,2 +200,3 @@ filter(predicate: (fragment: NamedFragmentDefinition) => boolean): NamedFragments | undefined; | ||
constructor(parentType: CompositeType, keyedSelections?: Map<string, Selection>); | ||
minimizeSelectionSet(namedFragments?: NamedFragments, seenSelections?: Map<string, [SelectionSet, NamedFragmentDefinition][]>): [SelectionSet, NamedFragments]; | ||
selectionsInReverseOrder(): readonly Selection[]; | ||
@@ -250,2 +251,3 @@ selections(): readonly Selection[]; | ||
toString(expandFragments?: boolean, includeExternalBrackets?: boolean, indent?: string): string; | ||
isWorthUsing(): boolean; | ||
} | ||
@@ -252,0 +254,0 @@ export declare class SelectionSetUpdates { |
@@ -101,2 +101,3 @@ import { ASTNode, GraphQLError, StringValueNode } from "graphql"; | ||
static parse(input: string): FeatureVersion; | ||
static max(versions: Iterable<FeatureVersion>): FeatureVersion | undefined; | ||
satisfies(required: FeatureVersion): boolean; | ||
@@ -103,0 +104,0 @@ get series(): string; |
@@ -454,2 +454,11 @@ "use strict"; | ||
} | ||
static max(versions) { | ||
let max; | ||
for (const version of versions) { | ||
if (!max || version > max) { | ||
max = version; | ||
} | ||
} | ||
return max; | ||
} | ||
satisfies(required) { | ||
@@ -456,0 +465,0 @@ const { major, minor } = this; |
@@ -102,5 +102,4 @@ "use strict"; | ||
} | ||
getSourceDirectives(schema, errors) { | ||
getSourceDirectives(schema) { | ||
const result = {}; | ||
let federationVersion; | ||
schema.schemaDefinition.appliedDirectivesOf('link') | ||
@@ -126,11 +125,3 @@ .forEach(linkDirective => { | ||
} | ||
if (featureUrl && featureUrl.name === 'federation') { | ||
federationVersion = featureUrl.version; | ||
} | ||
}); | ||
if (result.sourceAPI || result.sourceType || result.sourceField) { | ||
if (!federationVersion || federationVersion.lt(this.minimumFederationVersion)) { | ||
errors.push(error_1.ERRORS.SOURCE_FEDERATION_VERSION_REQUIRED.err(`Schemas that @link to ${exports.sourceIdentity} must also @link to federation version ${this.minimumFederationVersion} or later (found ${federationVersion})`)); | ||
} | ||
} | ||
return result; | ||
@@ -140,3 +131,3 @@ } | ||
const errors = super.validateSubgraphSchema(schema); | ||
const { sourceAPI, sourceType, sourceField, } = this.getSourceDirectives(schema, errors); | ||
const { sourceAPI, sourceType, sourceField, } = this.getSourceDirectives(schema); | ||
if (!(sourceAPI || sourceType || sourceField)) { | ||
@@ -143,0 +134,0 @@ return []; |
{ | ||
"name": "@apollo/federation-internals", | ||
"version": "2.7.1", | ||
"version": "2.7.2", | ||
"description": "Apollo Federation internal utilities", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -644,2 +644,24 @@ import { ASTNode, DirectiveLocation, GraphQLError, StringValueNode } from "graphql"; | ||
/** | ||
* Find the maximum version in a collection of versions, returning undefined in the case | ||
* that the collection is empty. | ||
* | ||
* # Example | ||
* ``` | ||
* expect(FeatureVersion.max([new FeatureVersion(1, 0), new FeatureVersion(2, 0)])).toBe(new FeatureVersion(2, 0)) | ||
* expect(FeatureVersion.max([])).toBe(undefined) | ||
* ``` | ||
*/ | ||
public static max(versions: Iterable<FeatureVersion>): FeatureVersion | undefined { | ||
let max: FeatureVersion | undefined; | ||
for (const version of versions) { | ||
if (!max || version > max) { | ||
max = version; | ||
} | ||
} | ||
return max; | ||
} | ||
/** | ||
* Return true if and only if this FeatureVersion satisfies the `required` version | ||
@@ -646,0 +668,0 @@ * |
@@ -150,3 +150,3 @@ import { DirectiveLocation, GraphQLError, Kind } from 'graphql'; | ||
private getSourceDirectives(schema: Schema, errors: GraphQLError[]) { | ||
private getSourceDirectives(schema: Schema) { | ||
const result: { | ||
@@ -158,4 +158,2 @@ sourceAPI?: DirectiveDefinition<SourceAPIDirectiveArgs>; | ||
let federationVersion: FeatureVersion | undefined; | ||
schema.schemaDefinition.appliedDirectivesOf<LinkDirectiveArgs>('link') | ||
@@ -180,21 +178,4 @@ .forEach(linkDirective => { | ||
} | ||
if (featureUrl && featureUrl.name === 'federation') { | ||
federationVersion = featureUrl.version; | ||
} | ||
}); | ||
if (result.sourceAPI || result.sourceType || result.sourceField) { | ||
// Since this subgraph uses at least one of the @source{API,Type,Field} | ||
// directives, it must also use v2.7 or later of federation. | ||
if (!federationVersion || federationVersion.lt(this.minimumFederationVersion)) { | ||
errors.push(ERRORS.SOURCE_FEDERATION_VERSION_REQUIRED.err( | ||
`Schemas that @link to ${ | ||
sourceIdentity | ||
} must also @link to federation version ${ | ||
this.minimumFederationVersion | ||
} or later (found ${federationVersion})`, | ||
)); | ||
} | ||
} | ||
return result; | ||
@@ -209,3 +190,3 @@ } | ||
sourceField, | ||
} = this.getSourceDirectives(schema, errors); | ||
} = this.getSourceDirectives(schema); | ||
@@ -212,0 +193,0 @@ if (!(sourceAPI || sourceType || sourceField)) { |
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 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 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
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
2110347
33661