Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
338 changes: 169 additions & 169 deletions composition-go/index.global.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion composition/src/errors/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
SemanticNonNullLevelsIndexOutOfBoundsErrorParams,
SemanticNonNullLevelsNonNullErrorParams,
} from './types';
import { UnresolvableFieldData } from '../resolvability-graph/utils';
import { UnresolvableFieldData } from '../resolvability-graph/utils/utils';
import {
AND_UPPER,
ARGUMENT,
Expand Down
5 changes: 4 additions & 1 deletion composition/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export * from './normalization/normalization';
export * from './normalization/types';
export * from './resolvability-graph/graph';
export * from './resolvability-graph/graph-nodes';
export * from './resolvability-graph/utils';
export * from './resolvability-graph/node-resolution-data/node-resolution-data';
export * from './resolvability-graph/node-resolution-data/types/params';
export * from './resolvability-graph/utils/types/types';
export * from './resolvability-graph/utils/utils';
export * from './router-compatibility-version/router-compatibility-version';
export * from './router-configuration/types';
export * from './router-configuration/utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const MUTATION = 'Mutation';
export const QUERY = 'Query';
export const SUBSCRIPTION = 'Subscription';

export const LITERAL_PERIOD = '.';
export const LITERAL_SPACE = ' ';
export const NOT_APPLICABLE = 'N/A';
export const QUOTATION_JOIN = '", "';

export const ROOT_TYPE_NAMES = new Set<string>([MUTATION, QUERY, SUBSCRIPTION]);
45 changes: 24 additions & 21 deletions composition/src/resolvability-graph/graph-nodes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { add, getEntriesNotInHashSet, getValueOrDefault } from '../utils/utils';
import { GraphFieldData } from '../utils/types';
import { FieldName, NodeName, SubgraphName, TypeName } from './types/types';

export class Edge {
edgeName: string;
Expand All @@ -23,20 +24,20 @@ export type GraphNodeOptions = {
};

export class GraphNode {
fieldDataByFieldName = new Map<string, GraphFieldData>();
fieldDataByName = new Map<FieldName, GraphFieldData>();
headToTailEdges = new Map<string, Edge>();
entityEdges: Array<Edge> = [];
nodeName: string;
entityEdges = new Array<Edge>();
nodeName: NodeName;
hasEntitySiblings = false;
isAbstract: boolean;
isInaccessible = false;
isLeaf = false;
isRootNode = false;
satisfiedFieldSets = new Set<string>();
subgraphName: string;
typeName: string;
subgraphName: SubgraphName;
typeName: TypeName;

constructor(subgraphName: string, typeName: string, options?: GraphNodeOptions) {
constructor(subgraphName: SubgraphName, typeName: TypeName, options?: GraphNodeOptions) {
this.isAbstract = !!options?.isAbstract;
this.isLeaf = !!options?.isLeaf;
this.nodeName = `${subgraphName}.${typeName}`;
Expand All @@ -48,7 +49,7 @@ export class GraphNode {
if (this.isAbstract) {
return;
}
const inaccessibleFieldNames = getEntriesNotInHashSet(this.headToTailEdges.keys(), this.fieldDataByFieldName);
const inaccessibleFieldNames = getEntriesNotInHashSet(this.headToTailEdges.keys(), this.fieldDataByName);
for (const fieldName of inaccessibleFieldNames) {
const headToTailEdge = this.headToTailEdges.get(fieldName);
if (!headToTailEdge) {
Expand All @@ -58,14 +59,14 @@ export class GraphNode {
}
}

getAllAccessibleEntityNodeNames(): Set<string> {
const accessibleEntityNodeNames = new Set<string>([this.nodeName]);
getAllAccessibleEntityNodeNames(): Set<NodeName> {
const accessibleEntityNodeNames = new Set<NodeName>([this.nodeName]);
this.getAccessibleEntityNodeNames(this, accessibleEntityNodeNames);
accessibleEntityNodeNames.delete(this.nodeName);
return accessibleEntityNodeNames;
}

getAccessibleEntityNodeNames(node: GraphNode, accessibleEntityNodeNames: Set<string>) {
getAccessibleEntityNodeNames(node: GraphNode, accessibleEntityNodeNames: Set<NodeName>) {
for (const edge of node.entityEdges) {
if (!add(accessibleEntityNodeNames, edge.node.nodeName)) {
continue;
Expand All @@ -76,20 +77,20 @@ export class GraphNode {
}

export class RootNode {
fieldDataByFieldName = new Map<string, GraphFieldData>();
headToShareableTailEdges = new Map<string, Array<Edge>>();
fieldDataByName = new Map<FieldName, GraphFieldData>();
headToSharedTailEdges = new Map<string, Array<Edge>>();
// It is used
isAbstract = false;
isRootNode = true;
typeName: string;
typeName: TypeName;

constructor(typeName: string) {
constructor(typeName: TypeName) {
this.typeName = typeName;
}

removeInaccessibleEdges(fieldDataByFieldName: Map<string, GraphFieldData>) {
for (const [fieldName, edges] of this.headToShareableTailEdges) {
if (fieldDataByFieldName.has(fieldName)) {
removeInaccessibleEdges(fieldDataByName: Map<FieldName, GraphFieldData>) {
for (const [fieldName, edges] of this.headToSharedTailEdges) {
if (fieldDataByName.has(fieldName)) {
continue;
}
for (const edge of edges) {
Expand All @@ -100,16 +101,18 @@ export class RootNode {
}

export class EntityDataNode {
fieldSetsByTargetSubgraphName = new Map<string, Set<string>>();
targetSubgraphNamesByFieldSet = new Map<string, Set<string>>();
fieldSetsByTargetSubgraphName = new Map<SubgraphName, Set<string>>();
targetSubgraphNamesByFieldSet = new Map<string, Set<SubgraphName>>();
typeName: string;

constructor(typeName: string) {
this.typeName = typeName;
}

addTargetSubgraphByFieldSet(fieldSet: string, targetSubgraphName: string) {
getValueOrDefault(this.targetSubgraphNamesByFieldSet, fieldSet, () => new Set<string>()).add(targetSubgraphName);
addTargetSubgraphByFieldSet(fieldSet: string, targetSubgraphName: SubgraphName) {
getValueOrDefault(this.targetSubgraphNamesByFieldSet, fieldSet, () => new Set<SubgraphName>()).add(
targetSubgraphName,
);
getValueOrDefault(this.fieldSetsByTargetSubgraphName, targetSubgraphName, () => new Set<string>()).add(fieldSet);
}
}
Loading
Loading