@apollo/federation-internals
Advanced tools
Comparing version 2.3.0-alpha.0 to 2.3.0-beta.1
@@ -109,2 +109,3 @@ import { ASTNode, GraphQLError, GraphQLErrorOptions, GraphQLFormattedError } from "graphql"; | ||
EMPTY_MERGED_ENUM_TYPE: ErrorCodeDefinition; | ||
SHAREABLE_HAS_MISMATCHED_RUNTIME_TYPES: ErrorCodeDefinition; | ||
SATISFIABILITY_ERROR: ErrorCodeDefinition; | ||
@@ -114,2 +115,3 @@ OVERRIDE_COLLISION_WITH_ANOTHER_DIRECTIVE: ErrorCodeDefinition; | ||
OVERRIDE_SOURCE_HAS_OVERRIDE: ErrorCodeDefinition; | ||
OVERRIDE_ON_INTERFACE: ErrorCodeDefinition; | ||
UNSUPPORTED_FEATURE: ErrorCodeDefinition; | ||
@@ -116,0 +118,0 @@ INVALID_FEDERATION_SUPERGRAPH: ErrorCodeDefinition; |
@@ -192,2 +192,3 @@ "use strict"; | ||
const EMPTY_MERGED_ENUM_TYPE = makeCodeDefinition('EMPTY_MERGED_ENUM_TYPE', 'An enum type has no value common to all the subgraphs that define the type. Merging that type would result in an invalid empty enum type.'); | ||
const SHAREABLE_HAS_MISMATCHED_RUNTIME_TYPES = makeCodeDefinition('SHAREABLE_HAS_MISMATCHED_RUNTIME_TYPES', 'A shareable field return type has mismatched possible runtime types in the subgraphs in which the field is declared. As shared fields must resolve the same way in all subgraphs, this is almost surely a mistake.'); | ||
const SATISFIABILITY_ERROR = makeCodeDefinition('SATISFIABILITY_ERROR', 'Subgraphs can be merged, but the resulting supergraph API would have queries that cannot be satisfied by those subgraphs.'); | ||
@@ -197,2 +198,3 @@ const OVERRIDE_FROM_SELF_ERROR = makeCodeDefinition('OVERRIDE_FROM_SELF_ERROR', 'Field with `@override` directive has "from" location that references its own subgraph.'); | ||
const OVERRIDE_COLLISION_WITH_ANOTHER_DIRECTIVE = makeCodeDefinition('OVERRIDE_COLLISION_WITH_ANOTHER_DIRECTIVE', 'The @override directive cannot be used on external fields, nor to override fields with either @external, @provides, or @requires.'); | ||
const OVERRIDE_ON_INTERFACE = makeCodeDefinition('OVERRIDE_ON_INTERFACE', 'The @override directive cannot be used on the fields of an interface type.', { addedIn: '2.3.0' }); | ||
const UNSUPPORTED_FEATURE = makeCodeDefinition('UNSUPPORTED_FEATURE', 'Indicates an error due to feature currently unsupported by federation.', { addedIn: '2.1.0' }); | ||
@@ -275,2 +277,3 @@ const INVALID_FEDERATION_SUPERGRAPH = makeCodeDefinition('INVALID_FEDERATION_SUPERGRAPH', 'Indicates that a schema provided for an Apollo Federation supergraph is not a valid supergraph schema.', { addedIn: '2.1.0' }); | ||
EMPTY_MERGED_ENUM_TYPE, | ||
SHAREABLE_HAS_MISMATCHED_RUNTIME_TYPES, | ||
SATISFIABILITY_ERROR, | ||
@@ -280,2 +283,3 @@ OVERRIDE_COLLISION_WITH_ANOTHER_DIRECTIVE, | ||
OVERRIDE_SOURCE_HAS_OVERRIDE, | ||
OVERRIDE_ON_INTERFACE, | ||
UNSUPPORTED_FEATURE, | ||
@@ -282,0 +286,0 @@ INVALID_FEDERATION_SUPERGRAPH, |
@@ -81,3 +81,3 @@ "use strict"; | ||
externalDirectiveSpec, | ||
tagSpec_1.TAG_VERSIONS.latest().tagDirectiveSpec, | ||
tagSpec_1.TAG_VERSIONS.find(new coreSpec_1.FeatureVersion(0, 2)).tagDirectiveSpec, | ||
extendsDirectiveSpec, | ||
@@ -136,2 +136,3 @@ ]; | ||
})); | ||
this.registerDirective(tagSpec_1.TAG_VERSIONS.find(new coreSpec_1.FeatureVersion(0, 3)).tagDirectiveSpec); | ||
} | ||
@@ -138,0 +139,0 @@ } |
import { DocumentNode, FieldNode, FragmentDefinitionNode, SelectionNode, SelectionSetNode } from "graphql"; | ||
import { Directive, DirectiveTargetElement, FieldDefinition, InterfaceType, ObjectType, Schema, SchemaRootKind, Variables, VariableDefinitions, CompositeType, DeferDirectiveArgs, Variable } from "./definitions"; | ||
import { Directive, DirectiveTargetElement, FieldDefinition, InterfaceType, ObjectType, Schema, SchemaRootKind, Variables, VariableDefinitions, CompositeType, DeferDirectiveArgs, Variable, Type } from "./definitions"; | ||
import { SetMultiMap } from "./utils"; | ||
@@ -34,2 +34,4 @@ declare abstract class AbstractOperationElement<T extends AbstractOperationElement<T>> extends DirectiveTargetElement<T> { | ||
updateForAddingTo(selectionSet: SelectionSet): Field<TArgs>; | ||
private canRebaseOn; | ||
typeIfAddedTo(parentType: CompositeType): Type | undefined; | ||
hasDefer(): boolean; | ||
@@ -52,2 +54,4 @@ deferDirectiveArgs(): undefined; | ||
updateForAddingTo(selectionSet: SelectionSet): FragmentElement; | ||
private canRebaseOn; | ||
castedTypeIfAddedTo(parentType: CompositeType): CompositeType | undefined; | ||
hasDefer(): boolean; | ||
@@ -174,2 +178,4 @@ hasStream(): boolean; | ||
contains(that: SelectionSet): boolean; | ||
minus(that: SelectionSet): SelectionSet; | ||
canRebaseOn(parentTypeToTest: CompositeType): boolean; | ||
validate(): void; | ||
@@ -208,2 +214,3 @@ isEmpty(): boolean; | ||
updateForAddingTo(selectionSet: SelectionSet): FieldSelection; | ||
canAddTo(parentType: CompositeType): boolean; | ||
toSelectionNode(): FieldNode; | ||
@@ -234,2 +241,3 @@ withUpdatedSubSelection(newSubSelection: SelectionSet | undefined): FieldSelection; | ||
abstract updateForAddingTo(selectionSet: SelectionSet): FragmentSelection; | ||
abstract canAddTo(parentType: CompositeType): boolean; | ||
abstract withUpdatedSubSelection(newSubSelection: SelectionSet | undefined): FragmentSelection; | ||
@@ -236,0 +244,0 @@ get parentType(): CompositeType; |
@@ -18,2 +18,3 @@ "use strict"; | ||
'https://specs.apollo.dev/tag/v0.2', | ||
'https://specs.apollo.dev/tag/v0.3', | ||
'https://specs.apollo.dev/inaccessible/v0.1', | ||
@@ -20,0 +21,0 @@ 'https://specs.apollo.dev/inaccessible/v0.2', |
@@ -12,2 +12,3 @@ import { DirectiveLocation, GraphQLError } from "graphql"; | ||
private isV01; | ||
private isV02; | ||
addElementsToSchema(schema: Schema): GraphQLError[]; | ||
@@ -14,0 +15,0 @@ tagDirective(schema: Schema): DirectiveDefinition<{ |
@@ -25,2 +25,6 @@ "use strict"; | ||
this.printedTagDefinition = 'directive @tag(name: String!) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION'; | ||
if (!this.isV02()) { | ||
this.tagLocations.push(graphql_1.DirectiveLocation.SCHEMA); | ||
this.printedTagDefinition = 'directive @tag(name: String!) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | SCHEMA'; | ||
} | ||
} | ||
@@ -40,2 +44,5 @@ this.tagDirectiveSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ | ||
} | ||
isV02() { | ||
return this.version.equals(new coreSpec_1.FeatureVersion(0, 2)); | ||
} | ||
addElementsToSchema(schema) { | ||
@@ -64,4 +71,5 @@ return this.addDirectiveSpec(schema, this.tagDirectiveSpec); | ||
.add(new TagSpecDefinition(new coreSpec_1.FeatureVersion(0, 1))) | ||
.add(new TagSpecDefinition(new coreSpec_1.FeatureVersion(0, 2))); | ||
.add(new TagSpecDefinition(new coreSpec_1.FeatureVersion(0, 2))) | ||
.add(new TagSpecDefinition(new coreSpec_1.FeatureVersion(0, 3))); | ||
(0, knownCoreFeatures_1.registerKnownFeature)(exports.TAG_VERSIONS); | ||
//# sourceMappingURL=tagSpec.js.map |
@@ -14,12 +14,9 @@ "use strict"; | ||
function sameType(t1, t2) { | ||
if (t1.kind !== t2.kind) { | ||
return false; | ||
} | ||
switch (t1.kind) { | ||
case 'ListType': | ||
return sameType(t1.ofType, t2.ofType); | ||
return (0, definitions_1.isListType)(t2) && sameType(t1.ofType, t2.ofType); | ||
case 'NonNullType': | ||
return sameType(t1.ofType, t2.ofType); | ||
return (0, definitions_1.isNonNullType)(t2) && sameType(t1.ofType, t2.ofType); | ||
default: | ||
return t1.name === t2.name; | ||
return (0, definitions_1.isNamedType)(t2) && t1.name === t2.name; | ||
} | ||
@@ -26,0 +23,0 @@ } |
@@ -273,3 +273,3 @@ "use strict"; | ||
} | ||
return first + (firstSep ? firstSep : sep) + toJoin.slice(1, toJoin.length - 1) + lastSep + last; | ||
return first + (firstSep ? firstSep : sep) + toJoin.slice(1, toJoin.length - 1).join(sep) + lastSep + last; | ||
} | ||
@@ -276,0 +276,0 @@ exports.joinStrings = joinStrings; |
{ | ||
"name": "@apollo/federation-internals", | ||
"version": "2.3.0-alpha.0", | ||
"version": "2.3.0-beta.1", | ||
"description": "Apollo Federation internal utilities", | ||
@@ -34,4 +34,3 @@ "main": "dist/index.js", | ||
"graphql": "^16.5.0" | ||
}, | ||
"gitHead": "b723008e72e58277bb366eb176b9f06e1949eff8" | ||
} | ||
} |
@@ -66,3 +66,7 @@ // Make this file a module (See: https://github.com/microsoft/TypeScript/issues/17736) | ||
const exp = expected[i]; | ||
const rec = deIndent(received[i]); | ||
let rec = deIndent(received[i]); | ||
// If the expected string as a trailing '\n', add one since we removed it. | ||
if (exp.charAt(exp.length - 1) === '\n') { | ||
rec = rec + '\n'; | ||
} | ||
if (!this.equals(exp, rec)) { | ||
@@ -69,0 +73,0 @@ pass = false; |
@@ -485,2 +485,7 @@ import { ASTNode, GraphQLError, GraphQLErrorOptions, GraphQLFormattedError } from "graphql"; | ||
const SHAREABLE_HAS_MISMATCHED_RUNTIME_TYPES = makeCodeDefinition( | ||
'SHAREABLE_HAS_MISMATCHED_RUNTIME_TYPES', | ||
'A shareable field return type has mismatched possible runtime types in the subgraphs in which the field is declared. As shared fields must resolve the same way in all subgraphs, this is almost surely a mistake.' | ||
); | ||
const SATISFIABILITY_ERROR = makeCodeDefinition( | ||
@@ -506,2 +511,8 @@ 'SATISFIABILITY_ERROR', | ||
const OVERRIDE_ON_INTERFACE = makeCodeDefinition( | ||
'OVERRIDE_ON_INTERFACE', | ||
'The @override directive cannot be used on the fields of an interface type.', | ||
{ addedIn: '2.3.0' }, | ||
); | ||
const UNSUPPORTED_FEATURE = makeCodeDefinition( | ||
@@ -621,2 +632,3 @@ 'UNSUPPORTED_FEATURE', | ||
EMPTY_MERGED_ENUM_TYPE, | ||
SHAREABLE_HAS_MISMATCHED_RUNTIME_TYPES, | ||
SATISFIABILITY_ERROR, | ||
@@ -626,2 +638,3 @@ OVERRIDE_COLLISION_WITH_ANOTHER_DIRECTIVE, | ||
OVERRIDE_SOURCE_HAS_OVERRIDE, | ||
OVERRIDE_ON_INTERFACE, | ||
UNSUPPORTED_FEATURE, | ||
@@ -628,0 +641,0 @@ INVALID_FEDERATION_SUPERGRAPH, |
@@ -97,3 +97,5 @@ import { | ||
externalDirectiveSpec, | ||
TAG_VERSIONS.latest().tagDirectiveSpec, | ||
// This should really be v0.1 instead of v0.2, but we can't change this to | ||
// v0.1 without checking whether anyone relied on the v0.2 behavior. | ||
TAG_VERSIONS.find(new FeatureVersion(0, 2))!.tagDirectiveSpec, | ||
extendsDirectiveSpec, | ||
@@ -164,2 +166,5 @@ ]; | ||
})); | ||
this.registerDirective( | ||
TAG_VERSIONS.find(new FeatureVersion(0, 3))!.tagDirectiveSpec | ||
); | ||
} | ||
@@ -166,0 +171,0 @@ } |
@@ -17,2 +17,3 @@ import { DocumentNode, GraphQLError } from "graphql"; | ||
'https://specs.apollo.dev/tag/v0.2', | ||
'https://specs.apollo.dev/tag/v0.3', | ||
'https://specs.apollo.dev/inaccessible/v0.1', | ||
@@ -19,0 +20,0 @@ 'https://specs.apollo.dev/inaccessible/v0.2', |
@@ -35,2 +35,6 @@ import { DirectiveLocation, GraphQLError } from "graphql"; | ||
this.printedTagDefinition = 'directive @tag(name: String!) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION'; | ||
if (!this.isV02()) { | ||
this.tagLocations.push(DirectiveLocation.SCHEMA); | ||
this.printedTagDefinition = 'directive @tag(name: String!) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | SCHEMA'; | ||
} | ||
} | ||
@@ -52,2 +56,6 @@ this.tagDirectiveSpec = createDirectiveSpecification({ | ||
private isV02() { | ||
return this.version.equals(new FeatureVersion(0, 2)) | ||
} | ||
addElementsToSchema(schema: Schema): GraphQLError[] { | ||
@@ -81,4 +89,5 @@ return this.addDirectiveSpec(schema, this.tagDirectiveSpec); | ||
.add(new TagSpecDefinition(new FeatureVersion(0, 1))) | ||
.add(new TagSpecDefinition(new FeatureVersion(0, 2))); | ||
.add(new TagSpecDefinition(new FeatureVersion(0, 2))) | ||
.add(new TagSpecDefinition(new FeatureVersion(0, 3))); | ||
registerKnownFeature(TAG_VERSIONS); |
@@ -10,8 +10,6 @@ /** | ||
isListType, | ||
isNamedType, | ||
isNonNullType, | ||
isObjectType, | ||
isUnionType, | ||
ListType, | ||
NamedType, | ||
NonNullType, | ||
ObjectType, | ||
@@ -36,22 +34,21 @@ Type, | ||
/** | ||
* Tests whether 2 types are the same type. | ||
* Tests whether 2 types are the "same" type. | ||
* | ||
* To be the same type, for this method, is defined as having the same "kind" | ||
* and either the same name, for named types or, for wrapper types, the same | ||
* wrapped type (applying this method recursively). | ||
* To be the same type, for this method, is defined as having the samee name for named types | ||
* or, for wrapper types, the same wrapper type and recursively same wrapped one. | ||
* | ||
* This method does not check that both types are from the same schema and does | ||
* not validate that the structure of named types is the same. | ||
* This method does not check that both types are from the same schema and does not validate | ||
* that the structure of named types is the same. Also note that it does not check the "kind" | ||
* of the type, which is actually relied on due to @interfaceObject (where the "same" type | ||
* can be an interface in one subgraph but an object type in another, while fundamentally being | ||
* the same type). | ||
*/ | ||
export function sameType(t1: Type, t2: Type): boolean { | ||
if (t1.kind !== t2.kind) { | ||
return false; | ||
} | ||
switch (t1.kind) { | ||
case 'ListType': | ||
return sameType(t1.ofType, (t2 as ListType<any>).ofType); | ||
return isListType(t2) && sameType(t1.ofType, t2.ofType); | ||
case 'NonNullType': | ||
return sameType(t1.ofType, (t2 as NonNullType<any>).ofType); | ||
return isNonNullType(t2) && sameType(t1.ofType, t2.ofType); | ||
default: | ||
return t1.name === (t2 as NamedType).name; | ||
return isNamedType(t2) && t1.name === t2.name; | ||
} | ||
@@ -58,0 +55,0 @@ } |
@@ -337,3 +337,3 @@ /** | ||
} | ||
return first + (firstSep ? firstSep : sep) + toJoin.slice(1, toJoin.length - 1) + lastSep + last; | ||
return first + (firstSep ? firstSep : sep) + toJoin.slice(1, toJoin.length - 1).join(sep) + lastSep + last; | ||
} | ||
@@ -340,0 +340,0 @@ |
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 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
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
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
2050210
34412