Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@apollo/federation-internals

Package Overview
Dependencies
Maintainers
1
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apollo/federation-internals - npm Package Compare versions

Comparing version 2.4.7 to 2.4.8

2

dist/coreSpec.js

@@ -477,4 +477,4 @@ "use strict";

}
exports.FeatureVersion = FeatureVersion;
FeatureVersion.VERSION_RE = /^v(\d+)\.(\d+)$/;
exports.FeatureVersion = FeatureVersion;
class FeatureUrl {

@@ -481,0 +481,0 @@ constructor(identity, name, version, element) {

@@ -17,3 +17,3 @@ "use strict";

FederationTypeName["FIELD_SET"] = "FieldSet";
})(FederationTypeName = exports.FederationTypeName || (exports.FederationTypeName = {}));
})(FederationTypeName || (exports.FederationTypeName = FederationTypeName = {}));
var FederationDirectiveName;

@@ -32,3 +32,3 @@ (function (FederationDirectiveName) {

FederationDirectiveName["INTERFACE_OBJECT"] = "interfaceObject";
})(FederationDirectiveName = exports.FederationDirectiveName || (exports.FederationDirectiveName = {}));
})(FederationDirectiveName || (exports.FederationDirectiveName = FederationDirectiveName = {}));
const fieldSetTypeSpec = (0, directiveAndTypeSpecification_1.createScalarTypeSpecification)({ name: FederationTypeName.FIELD_SET });

@@ -35,0 +35,0 @@ const fieldsArgument = { name: 'fields', type: (schema) => fieldSetType(schema) };

import { ArgumentNode, DocumentNode, FieldNode, FragmentDefinitionNode, SelectionNode, SelectionSetNode } from "graphql";
import { Directive, DirectiveTargetElement, FieldDefinition, InterfaceType, ObjectType, Schema, SchemaRootKind, VariableCollector, VariableDefinitions, CompositeType, DeferDirectiveArgs, Variable, Type, Variables, NamedType } from "./definitions";
import { SetMultiMap } from "./utils";
import { MultiMap, SetMultiMap } from "./utils";
declare abstract class AbstractOperationElement<T extends AbstractOperationElement<T>> extends DirectiveTargetElement<T> {

@@ -23,3 +23,3 @@ private attachements?;

readonly definition: FieldDefinition<CompositeType>;
private readonly args?;
readonly args?: TArgs | undefined;
readonly alias?: string | undefined;

@@ -97,5 +97,7 @@ readonly kind: "Field";

constructor(schema: Schema, rootKind: SchemaRootKind, selectionSet: SelectionSet, variableDefinitions: VariableDefinitions, fragments?: NamedFragments | undefined, name?: string | undefined);
private withUpdatedSelectionSet;
private withUpdatedSelectionSetAndFragments;
optimize(fragments?: NamedFragments, minUsagesToOptimize?: number): Operation;
expandAllFragments(): Operation;
trimUnsatisfiableBranches(): Operation;
normalize(): Operation;
withoutDefer(labelsToRemove?: Set<string>): Operation;

@@ -111,2 +113,6 @@ withNormalizedDefer(): {

}
export type FragmentRestrictionAtType = {
selectionSet: SelectionSet;
validator?: FieldsConflictValidator;
};
export declare class NamedFragmentDefinition extends DirectiveTargetElement<NamedFragmentDefinition> {

@@ -128,4 +134,5 @@ readonly name: string;

toFragmentDefinitionNode(): FragmentDefinitionNode;
canApplyAtType(type: CompositeType): boolean;
expandedSelectionSetAtType(type: CompositeType): SelectionSet;
canApplyDirectlyAtType(type: CompositeType): boolean;
expandedSelectionSetAtType(type: CompositeType): FragmentRestrictionAtType;
private computeExpandedSelectionSetAtType;
includes(otherFragment: string): boolean;

@@ -142,3 +149,3 @@ private computeIncludedFragmentNames;

addIfNotExist(fragment: NamedFragmentDefinition): void;
maybeApplyingAtType(type: CompositeType): NamedFragmentDefinition[];
maybeApplyingDirectlyAtType(type: CompositeType): NamedFragmentDefinition[];
get(name: string): NamedFragmentDefinition | undefined;

@@ -174,2 +181,6 @@ has(name: string): boolean;

}
export type CollectedFieldsInSet = {
path: string[];
field: FieldSelection;
}[];
export declare class SelectionSet {

@@ -183,6 +194,5 @@ readonly parentType: CompositeType;

hasTopLevelTypenameField(): boolean;
fieldsInSet(): {
path: string[];
field: FieldSelection;
}[];
fieldsInSet(): CollectedFieldsInSet;
fieldsByResponseName(): MultiMap<string, FieldSelection>;
private collectFieldsByResponseName;
usedVariables(): Variables;

@@ -192,5 +202,6 @@ collectVariables(collector: VariableCollector): void;

optimize(fragments?: NamedFragments): SelectionSet;
optimizeSelections(fragments: NamedFragments): SelectionSet;
optimizeSelections(fragments: NamedFragments, validator: FieldsConflictValidator): SelectionSet;
expandFragments(updatedFragments?: NamedFragments): SelectionSet;
trimUnsatisfiableBranches(parentType: CompositeType, options?: {
normalize({ parentType, recursive }: {
parentType: CompositeType;
recursive?: boolean;

@@ -205,2 +216,3 @@ }): SelectionSet;

filter(predicate: (selection: Selection) => boolean): SelectionSet;
filterRecursiveDepthFirst(predicate: (selection: Selection) => boolean): SelectionSet;
withoutEmptyBranches(): SelectionSet | undefined;

@@ -210,7 +222,4 @@ rebaseOn(parentType: CompositeType, fragments: NamedFragments | undefined): SelectionSet;

contains(that: SelectionSet): ContainsResult;
diffWithNamedFragmentIfContained(candidate: NamedFragmentDefinition, parentType: CompositeType, fragments: NamedFragments): {
contains: boolean;
diff?: SelectionSet;
};
minus(that: SelectionSet): SelectionSet;
intersectionWith(that: SelectionSet): SelectionSet;
canRebaseOn(parentTypeToTest: CompositeType): boolean;

@@ -236,2 +245,3 @@ validate(variableDefinitions: VariableDefinitions): void;

toSelectionSet(parentType: CompositeType, fragments?: NamedFragments): SelectionSet;
toString(): string;
}

@@ -274,3 +284,3 @@ export declare class MutableSelectionSet<TMemoizedValue extends {

abstract key(): string;
abstract optimize(fragments: NamedFragments): Selection;
abstract optimize(fragments: NamedFragments, validator: FieldsConflictValidator): Selection;
abstract toSelectionNode(): SelectionNode;

@@ -291,3 +301,4 @@ abstract validate(variableDefinitions: VariableDefinitions): void;

abstract expandFragments(updatedFragments: NamedFragments | undefined): TOwnType | readonly Selection[];
abstract trimUnsatisfiableBranches(parentType: CompositeType, options?: {
abstract normalize(args: {
parentType: CompositeType;
recursive?: boolean;

@@ -297,9 +308,23 @@ }): TOwnType | SelectionSet | undefined;

minus(that: Selection): TOwnType | undefined;
protected tryOptimizeSubselectionWithFragments({ parentType, subSelection, fragments, canUseFullMatchingFragment, }: {
intersectionWith(that: Selection): TOwnType | undefined;
protected tryOptimizeSubselectionWithFragments({ parentType, subSelection, fragments, validator, canUseFullMatchingFragment, }: {
parentType: CompositeType;
subSelection: SelectionSet;
fragments: NamedFragments;
validator: FieldsConflictValidator;
canUseFullMatchingFragment: (match: NamedFragmentDefinition) => boolean;
}): SelectionSet | NamedFragmentDefinition;
}
declare class FieldsConflictValidator {
private readonly byResponseName;
private usedSpreadTrimmedPartAtLevel?;
private constructor();
static build(s: SelectionSet): FieldsConflictValidator;
private static forLevel;
forField(field: Field): FieldsConflictValidator;
checkCanReuseFragmentAndTrackIt(fragment: FragmentRestrictionAtType): boolean;
doMergeWith(that: FieldsConflictValidator): boolean;
hasSameResponseShapeThan(that: FieldsConflictValidator): boolean;
toString(indent?: string): string;
}
export declare class FieldSelection extends AbstractSelection<Field<any>, undefined, FieldSelection> {

@@ -314,4 +339,4 @@ private readonly _selectionSet?;

key(): string;
optimize(fragments: NamedFragments): Selection;
filter(predicate: (selection: Selection) => boolean): FieldSelection | undefined;
optimize(fragments: NamedFragments, validator: FieldsConflictValidator): Selection;
filterRecursiveDepthFirst(predicate: (selection: Selection) => boolean): FieldSelection | undefined;
validate(variableDefinitions: VariableDefinitions): void;

@@ -324,3 +349,4 @@ rebaseOn(parentType: CompositeType, fragments: NamedFragments | undefined): FieldSelection;

hasDefer(): boolean;
trimUnsatisfiableBranches(_: CompositeType, options?: {
normalize({ parentType, recursive }: {
parentType: CompositeType;
recursive?: boolean;

@@ -338,3 +364,3 @@ }): FieldSelection;

protected validateDeferAndStream(): void;
filter(predicate: (selection: Selection) => boolean): FragmentSelection | undefined;
filterRecursiveDepthFirst(predicate: (selection: Selection) => boolean): FragmentSelection | undefined;
hasDefer(): boolean;

@@ -341,0 +367,0 @@ abstract equals(that: Selection): boolean;

@@ -9,2 +9,3 @@ import { AbstractType, InterfaceType, ObjectType, Type, UnionType } from "./definitions";

export declare function isStrictSubtype(type: Type, maybeSubType: Type, allowedRules?: SubtypingRule[], unionMembershipTester?: (union: UnionType, maybeMember: ObjectType) => boolean, implementsInterfaceTester?: (maybeImplementer: ObjectType | InterfaceType, itf: InterfaceType) => boolean): boolean;
export declare function typesCanBeMerged(t1: Type, t2: Type): boolean;
//# sourceMappingURL=types.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isStrictSubtype = exports.isSubtype = exports.isDirectSubtype = exports.sameType = exports.DEFAULT_SUBTYPING_RULES = exports.ALL_SUBTYPING_RULES = void 0;
exports.typesCanBeMerged = exports.isStrictSubtype = exports.isSubtype = exports.isDirectSubtype = exports.sameType = exports.DEFAULT_SUBTYPING_RULES = exports.ALL_SUBTYPING_RULES = void 0;
const definitions_1 = require("./definitions");

@@ -64,2 +64,15 @@ exports.ALL_SUBTYPING_RULES = [

exports.isStrictSubtype = isStrictSubtype;
function typesCanBeMerged(t1, t2) {
if ((0, definitions_1.isNonNullType)(t1)) {
return (0, definitions_1.isNonNullType)(t2) ? typesCanBeMerged(t1.ofType, t2.ofType) : false;
}
if ((0, definitions_1.isListType)(t1)) {
return (0, definitions_1.isListType)(t2) ? typesCanBeMerged(t1.ofType, t2.ofType) : false;
}
if ((0, definitions_1.isCompositeType)(t1)) {
return (0, definitions_1.isCompositeType)(t2);
}
return sameType(t1, t2);
}
exports.typesCanBeMerged = typesCanBeMerged;
//# sourceMappingURL=types.js.map
{
"name": "@apollo/federation-internals",
"version": "2.4.7",
"version": "2.4.8",
"description": "Apollo Federation internal utilities",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -6,4 +6,5 @@ /**

import {
AbstractType,
AbstractType,
InterfaceType,
isCompositeType,
isInterfaceType,

@@ -148,1 +149,21 @@ isListType,

}
/**
* This essentially follows the beginning of https://spec.graphql.org/draft/#SameResponseShape().
* That is, the types cannot be merged unless:
* - they have the same nullability and "list-ability", potentially recursively.
* - their base type is either both composite, or are the same type.
*/
export function typesCanBeMerged(t1: Type, t2: Type): boolean {
if (isNonNullType(t1)) {
return isNonNullType(t2) ? typesCanBeMerged(t1.ofType, t2.ofType) : false;
}
if (isListType(t1)) {
return isListType(t2) ? typesCanBeMerged(t1.ofType, t2.ofType) : false;
}
if (isCompositeType(t1)) {
return isCompositeType(t2);
}
return sameType(t1, t2);
}

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 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 too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc