Skip to content

Commit efa4cdf

Browse files
committed
chore: remove requestScoped from queryCache branch (queryCache becomes 4/5)
Reorders the stack so @openfed__queryCache/@openfed__is sits directly on main as the 4th PR. The @openfed__requestScoped feature is removed here and re-applied on top in the requestScoped branch (now 5/5). The requestScoped assertions in shared/test/entity-caching.test.ts move to that PR. Proto regenerated (request_scoped_configurations field 4 dropped; query_cache remains field 5).
1 parent fc06034 commit efa4cdf

18 files changed

Lines changed: 708 additions & 1257 deletions

File tree

composition/src/directive-definition-data/directive-definition-data.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ import {
9090
NEGATIVE_CACHE_TTL,
9191
PARTIAL_CACHE_LOAD,
9292
OPENFED_QUERY_CACHE,
93-
OPENFED_REQUEST_SCOPED,
9493
SHADOW_MODE,
9594
} from '../utils/string-constants';
9695
import {
@@ -128,7 +127,6 @@ import {
128127
OPENFED_ENTITY_CACHE_DEFINITION,
129128
OPENFED_IS_DEFINITION,
130129
OPENFED_QUERY_CACHE_DEFINITION,
131-
OPENFED_REQUEST_SCOPED_DEFINITION,
132130
SPECIFIED_BY_DEFINITION,
133131
SUBSCRIPTION_FILTER_DEFINITION,
134132
TAG_DEFINITION,
@@ -1108,21 +1106,3 @@ export const IS_DEFINITION_DATA = newDirectiveDefinitionData({
11081106
node: OPENFED_IS_DEFINITION,
11091107
requiredArgumentNames: new Set<ArgumentName>([FIELDS]),
11101108
});
1111-
1112-
export const REQUEST_SCOPED_DEFINITION_DATA = newDirectiveDefinitionData({
1113-
argumentDataByName: new Map<ArgumentName, DirectiveArgumentData>([
1114-
[
1115-
KEY,
1116-
newDirectiveArgumentData({
1117-
directive: `@${OPENFED_REQUEST_SCOPED}`,
1118-
name: KEY,
1119-
namedTypeKind: Kind.SCALAR_TYPE_DEFINITION,
1120-
typeNode: REQUIRED_STRING_TYPE_NODE,
1121-
}),
1122-
],
1123-
]),
1124-
locations: new Set<DirectiveLocation>([FIELD_DEFINITION_UPPER]),
1125-
name: OPENFED_REQUEST_SCOPED,
1126-
node: OPENFED_REQUEST_SCOPED_DEFINITION,
1127-
requiredArgumentNames: new Set<ArgumentName>([KEY]),
1128-
});

composition/src/router-configuration/types.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,6 @@ export type RequiredFieldConfiguration = {
8787
disableEntityResolver?: boolean;
8888
};
8989

90-
export type RequestScopedConfiguration = {
91-
fieldName: FieldName;
92-
typeName: TypeName;
93-
// L1 cache key used to store/lookup this field's value for the duration of a request.
94-
// Format: "{subgraphName}.{key}" where `key` is the @openfed__requestScoped(key:) argument.
95-
// All fields in the same subgraph declaring @openfed__requestScoped with the same key share
96-
// the same L1 entry — the first one to resolve populates it, subsequent ones inject
97-
// from it (subject to widening checks and alias-aware normalization).
98-
l1Key: string;
99-
};
100-
10190
export type ConfigurationData = {
10291
fieldNames: Set<FieldName>;
10392
isRootNode: boolean;
@@ -186,8 +175,6 @@ export type EntityCachingConfiguration = {
186175
cachePopulateConfigurations: Array<CachePopulateConfiguration>;
187176
// Attached to an entity type's ConfigurationData (e.g. "Product") from @openfed__entityCache.
188177
entityCacheConfigurations: Array<EntityCacheConfiguration>;
189-
// Attached to a field's ConfigurationData from @openfed__requestScoped.
190-
requestScopedConfigurations: Array<RequestScopedConfiguration>;
191178
// Attached to the Query type's ConfigurationData from @openfed__queryCache.
192179
queryCacheConfigurations?: Array<QueryCacheConfig>;
193180
};

composition/src/router-configuration/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export function getOrInitializeEntityCaching(configurationData: ConfigurationDat
2222
cacheInvalidateConfigurations: [],
2323
cachePopulateConfigurations: [],
2424
entityCacheConfigurations: [],
25-
requestScopedConfigurations: [],
2625
};
2726
}
2827

composition/src/utils/string-constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ export const REASON = 'reason';
135135
export const REQUEST = 'request';
136136
export const REQUIRE_FETCH_REASONS = 'openfed__requireFetchReasons';
137137
export const REQUIRE_ONE_SLICING_ARGUMENT = 'requireOneSlicingArgument';
138-
export const OPENFED_REQUEST_SCOPED = 'openfed__requestScoped';
139138
export const REQUIRES = 'requires';
140139
export const REQUIRES_SCOPES = 'requiresScopes';
141140
export const RESOLVABLE = 'resolvable';

composition/src/v1/constants/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
OPENFED_ENTITY_CACHE,
1313
OPENFED_IS,
1414
OPENFED_QUERY_CACHE,
15-
OPENFED_REQUEST_SCOPED,
1615
DEPRECATED,
1716
EDFS_KAFKA_PUBLISH,
1817
EDFS_KAFKA_SUBSCRIBE,
@@ -85,7 +84,6 @@ import {
8584
OPENFED_ENTITY_CACHE_DEFINITION,
8685
OPENFED_IS_DEFINITION,
8786
OPENFED_QUERY_CACHE_DEFINITION,
88-
OPENFED_REQUEST_SCOPED_DEFINITION,
8987
} from './directive-definitions';
9088

9189
export const DIRECTIVE_DEFINITION_BY_NAME: ReadonlyMap<DirectiveName, DirectiveDefinitionNode> = new Map<
@@ -103,7 +101,6 @@ export const DIRECTIVE_DEFINITION_BY_NAME: ReadonlyMap<DirectiveName, DirectiveD
103101
[OPENFED_CACHE_POPULATE, OPENFED_CACHE_POPULATE_DEFINITION],
104102
[OPENFED_QUERY_CACHE, OPENFED_QUERY_CACHE_DEFINITION],
105103
[OPENFED_IS, OPENFED_IS_DEFINITION],
106-
[OPENFED_REQUEST_SCOPED, OPENFED_REQUEST_SCOPED_DEFINITION],
107104
[DEPRECATED, DEPRECATED_DEFINITION],
108105
[EDFS_KAFKA_PUBLISH, EDFS_KAFKA_PUBLISH_DEFINITION],
109106
[EDFS_KAFKA_SUBSCRIBE, EDFS_KAFKA_SUBSCRIBE_DEFINITION],

composition/src/v1/constants/directive-definitions.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ import {
9090
NEGATIVE_CACHE_TTL,
9191
PARTIAL_CACHE_LOAD,
9292
OPENFED_QUERY_CACHE,
93-
OPENFED_REQUEST_SCOPED,
9493
SHADOW_MODE,
9594
} from '../../utils/string-constants';
9695
import {
@@ -938,21 +937,3 @@ export const OPENFED_IS_DEFINITION: DirectiveDefinitionNode = {
938937
name: stringToNameNode(OPENFED_IS),
939938
repeatable: false,
940939
};
941-
942-
// @openfed__requestScoped(key: String!) on FIELD_DEFINITION
943-
export const OPENFED_REQUEST_SCOPED_DEFINITION: DirectiveDefinitionNode = {
944-
arguments: [
945-
{
946-
kind: Kind.INPUT_VALUE_DEFINITION,
947-
name: stringToNameNode(KEY),
948-
type: {
949-
kind: Kind.NON_NULL_TYPE,
950-
type: stringToNamedTypeNode(STRING_SCALAR),
951-
},
952-
},
953-
],
954-
kind: Kind.DIRECTIVE_DEFINITION,
955-
locations: stringArrayToNameNodeArray([FIELD_DEFINITION_UPPER]),
956-
name: stringToNameNode(OPENFED_REQUEST_SCOPED),
957-
repeatable: false,
958-
};

composition/src/v1/normalization/normalization-factory.ts

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ import {
216216
type EntityKeyMappingConfig,
217217
type FieldMappingConfig,
218218
type QueryCacheConfig,
219-
type RequestScopedConfiguration,
220219
} from '../../router-configuration/types';
221220
import { printTypeNode } from '@graphql-tools/merge';
222221
import {
@@ -227,7 +226,6 @@ import {
227226
fieldAlreadyProvidedWarning,
228227
invalidExternalFieldWarning,
229228
nonExternalConditionalFieldWarning,
230-
requestScopedSingleFieldWarning,
231229
singleSubgraphInputFieldOneOfWarning,
232230
unimplementedInterfaceOutputTypeWarning,
233231
queryCacheReturnEntityMissingEntityCacheWarning,
@@ -387,7 +385,6 @@ import {
387385
LITERAL_OPEN_BRACE,
388386
LITERAL_SPACE,
389387
OPENFED_QUERY_CACHE,
390-
OPENFED_REQUEST_SCOPED,
391388
} from '../../utils/string-constants';
392389
import { MAX_INT32 } from '../../utils/integer-constants';
393390
import {
@@ -421,7 +418,6 @@ import {
421418
type UpsertInputObjectResult,
422419
type ValidateDirectiveParams,
423420
type QueryCacheDirectiveNode,
424-
type RequestScopedDirectiveNode,
425421
} from './types/types';
426422
import {
427423
getOrInitializeEntityCaching,
@@ -540,7 +536,6 @@ export class NormalizationFactory {
540536
referencedDirectiveNames = new Set<DirectiveName>();
541537
referencedTypeNames = new Set<TypeName>();
542538
renamedParentTypeName = '';
543-
requestScopedFieldCoordsByL1Key = new Map<string, Array<string>>();
544539
schemaData: SchemaData;
545540
subgraphName: SubgraphName;
546541
unvalidatedExternalFieldCoords = new Set<string>();
@@ -4071,7 +4066,7 @@ export class NormalizationFactory {
40714066

40724067
/* validateDirectives() (run earlier in normalize()) has already guaranteed each argument's type —
40734068
* Int for maxAge/negativeCacheTTL, Boolean for the flags — so the generic ConstDirectiveNode is
4074-
* narrowed once to the precise typed node, mirroring RequestScopedDirectiveNode/ComposeDirectiveNode.
4069+
* narrowed once to the precise typed node, mirroring ComposeDirectiveNode.
40754070
* Optional arguments may be absent (definition defaults are not materialized onto the usage AST),
40764071
* so the config starts at the directive's documented defaults and each present argument overrides it.
40774072
*/
@@ -4314,7 +4309,7 @@ export class NormalizationFactory {
43144309
}
43154310
// validateDirectives() has already guaranteed the argument types (Int maxAge, Boolean flags), so the
43164311
// generic ConstDirectiveNode is narrowed once to the precise typed node — mirroring
4317-
// EntityCacheDirectiveNode/RequestScopedDirectiveNode. Optional args may be absent (definition defaults
4312+
// EntityCacheDirectiveNode. Optional args may be absent (definition defaults
43184313
// are not materialized onto the usage AST), so each defaults here and present args override.
43194314
const queryCacheDirective = fieldData.directivesByName.get(OPENFED_QUERY_CACHE)![0] as QueryCacheDirectiveNode;
43204315
let maxAgeSeconds = 0;
@@ -5204,38 +5199,6 @@ export class NormalizationFactory {
52045199
return [];
52055200
}
52065201

5207-
// Attaches a single field annotated with @openfed__requestScoped to its type's configurationData. A field
5208-
// is both a reader and writer of the coordinate L1 — no receiver/provider. Fields with the same `key` share
5209-
// the same L1 entry: whichever is resolved first populates it, subsequent ones inject from it.
5210-
extractRequestScopedConfig(fieldData: FieldData) {
5211-
const directives = fieldData.directivesByName.get(OPENFED_REQUEST_SCOPED);
5212-
if (!directives) {
5213-
return;
5214-
}
5215-
// validateDirectives() (run earlier in normalize()) has already guaranteed a single, non-repeated
5216-
// @openfed__requestScoped with a required String `key`, so the generic ConstDirectiveNode can be
5217-
// narrowed to the precise typed node — mirroring handleComposeDirective()/ComposeDirectiveNode.
5218-
const directive = directives[0] as RequestScopedDirectiveNode;
5219-
const keyArg = directive.arguments.find((arg) => arg.name.value === KEY);
5220-
if (!keyArg) {
5221-
return;
5222-
}
5223-
5224-
const config: RequestScopedConfiguration = {
5225-
fieldName: fieldData.name,
5226-
typeName: fieldData.renamedParentTypeName,
5227-
l1Key: `${this.subgraphName}.${keyArg.value.value}`,
5228-
};
5229-
const configurationData = getValueOrDefault(this.configurationDataByTypeName, fieldData.renamedParentTypeName, () =>
5230-
newConfigurationData(false, fieldData.renamedParentTypeName),
5231-
);
5232-
getOrInitializeEntityCaching(configurationData).requestScopedConfigurations.push(config);
5233-
// Track field coords per L1 key so the single-field warning can be emitted after the walk completes.
5234-
getValueOrDefault(this.requestScopedFieldCoordsByL1Key, config.l1Key, () => []).push(
5235-
`${config.typeName}.${config.fieldName}`,
5236-
);
5237-
}
5238-
52395202
addFieldNamesToConfigurationData(fieldDataByFieldName: Map<string, FieldData>, configurationData: ConfigurationData) {
52405203
const externalFieldNames = new Set<string>();
52415204
for (const [fieldName, fieldData] of fieldDataByFieldName) {
@@ -5426,7 +5389,6 @@ export class NormalizationFactory {
54265389
for (const [fieldName, fieldData] of parentData.fieldDataByName) {
54275390
if (isObject) {
54285391
this.handleFieldCacheDirectives(fieldData);
5429-
this.extractRequestScopedConfig(fieldData);
54305392

54315393
// @openfed__queryCache extraction and @openfed__is placement validation. Key field sets and
54325394
// entity-cache configs are already finalized at this point in normalize() (populated by
@@ -5540,21 +5502,6 @@ export class NormalizationFactory {
55405502
}
55415503
}
55425504
}
5543-
// @openfed__requestScoped is meaningless unless >= 2 fields share a key (there'd be no second reader to
5544-
// benefit), so warn for any key used on only one field across the subgraph. extractRequestScopedConfig()
5545-
// populated requestScopedFieldCoordsByL1Key during the type walk above.
5546-
for (const [l1Key, fieldCoordsList] of this.requestScopedFieldCoordsByL1Key) {
5547-
if (fieldCoordsList.length === 1) {
5548-
this.warnings.push(
5549-
requestScopedSingleFieldWarning({
5550-
subgraphName: this.subgraphName,
5551-
// l1Key is `${this.subgraphName}.${key}`, so strip the prefix to recover the original key.
5552-
key: l1Key.slice(this.subgraphName.length + 1),
5553-
fieldCoords: fieldCoordsList[0],
5554-
}),
5555-
);
5556-
}
5557-
}
55585505
this.isSubgraphEventDrivenGraph = this.edfsDirectiveReferences.size > 0;
55595506
// this is where @provides and @requires configurations are added to the ConfigurationData
55605507
this.addValidConditionalFieldSetConfigurations();

composition/src/v1/normalization/types/types.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,6 @@ export type ComposeDirectiveArgumentNode = {
148148
readonly loc?: Location;
149149
};
150150

151-
export type RequestScopedDirectiveNode = {
152-
readonly arguments: ReadonlyArray<RequestScopedArgumentNode>;
153-
readonly kind: Kind.DIRECTIVE;
154-
readonly name: NameNode;
155-
readonly loc?: Location;
156-
};
157-
158-
export type RequestScopedArgumentNode = {
159-
readonly kind: Kind.ARGUMENT;
160-
readonly name: NameNode;
161-
readonly value: StringValueNode; // key: String! — guaranteed by validateDirectives()
162-
readonly loc?: Location;
163-
};
164-
165151
export type EntityCacheDirectiveNode = {
166152
readonly arguments:
167153
| readonly [MaxAgeArgumentNode]

composition/src/v1/normalization/utils.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ import {
8181
CACHE_POPULATE_DEFINITION_DATA,
8282
IS_DEFINITION_DATA,
8383
QUERY_CACHE_DEFINITION_DATA,
84-
REQUEST_SCOPED_DEFINITION_DATA,
8584
} from '../../directive-definition-data/directive-definition-data';
8685
import {
8786
AS,
@@ -94,7 +93,6 @@ import {
9493
COST,
9594
OPENFED_IS,
9695
OPENFED_QUERY_CACHE,
97-
OPENFED_REQUEST_SCOPED,
9896
DEPRECATED,
9997
EDFS_KAFKA_PUBLISH,
10098
EDFS_KAFKA_SUBSCRIBE,
@@ -490,7 +488,6 @@ export function initializeDirectiveDefinitionDatas(): Map<string, DirectiveDefin
490488
[OPENFED_CACHE_POPULATE, CACHE_POPULATE_DEFINITION_DATA],
491489
[OPENFED_QUERY_CACHE, QUERY_CACHE_DEFINITION_DATA],
492490
[OPENFED_IS, IS_DEFINITION_DATA],
493-
[OPENFED_REQUEST_SCOPED, REQUEST_SCOPED_DEFINITION_DATA],
494491
[DEPRECATED, DEPRECATED_DEFINITION_DATA],
495492
[EDFS_KAFKA_PUBLISH, KAFKA_PUBLISH_DEFINITION_DATA],
496493
[EDFS_KAFKA_SUBSCRIBE, KAFKA_SUBSCRIBE_DEFINITION_DATA],

composition/src/v1/warnings/params.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ export type InvalidRepeatedComposedDirectiveWarningParams = {
1717
printedDirective: string;
1818
};
1919

20-
export type RequestScopedSingleFieldWarningParams = {
21-
subgraphName: SubgraphName;
22-
key: string;
23-
fieldCoords: string;
24-
};
25-
2620
export type QueryCacheReturnEntityMissingEntityCacheWarningParams = {
2721
subgraphName: SubgraphName;
2822
fieldCoords: FieldName;

0 commit comments

Comments
 (0)