Skip to content

Commit 4e901ed

Browse files
committed
feat: adjust persisted document id format for specification
1 parent 5832d94 commit 4e901ed

File tree

7 files changed

+11
-9
lines changed

7 files changed

+11
-9
lines changed

packages/libraries/apollo/tests/persisted-documents.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ test('usage reporting for persisted document', async () => {
265265
{
266266
metadata: {},
267267
operationMapKey: 'ace78a32bbf8a79071356e5d5b13c5c83baf4e14',
268-
persistedDocumentHash: 'client-name/client-version/hash',
268+
persistedDocumentHash: 'client-name~client-version~hash',
269269
},
270270
]);
271271

packages/libraries/core/src/client/persisted-documents.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export function createPersistedDocuments(config: PersistedDocumentsConfiguration
3232
return document;
3333
}
3434

35-
const response = await fetch(config.cdn.endpoint + '/apps/' + documentId, {
35+
const cdnHttpId = documentId.replaceAll('~', '/');
36+
37+
const response = await fetch(config.cdn.endpoint + '/apps/' + cdnHttpId, {
3638
method: 'GET',
3739
headers: {
3840
'X-Hive-CDN-Key': config.cdn.accessToken,

packages/libraries/yoga/tests/persisted-documents.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ test('usage reporting for persisted document', async () => {
363363
{
364364
metadata: {},
365365
operationMapKey: 'ace78a32bbf8a79071356e5d5b13c5c83baf4e14',
366-
persistedDocumentHash: 'client-name/client-version/hash',
366+
persistedDocumentHash: 'client-name~client-version~hash',
367367
},
368368
]);
369369

@@ -476,7 +476,7 @@ test('usage reporting for persisted document (subscription)', async () => {
476476
{
477477
metadata: {},
478478
operationMapKey: '74cf03b67c3846231d04927b02e1fca45e727223',
479-
persistedDocumentHash: 'client-name/client-version/hash',
479+
persistedDocumentHash: 'client-name~client-version~hash',
480480
},
481481
]);
482482

packages/services/usage/src/usage-processor-2.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function usageProcessorV2(
125125

126126
let client: ClientMetadata | undefined;
127127
if (operation.persistedDocumentHash) {
128-
const [name, version] = operation.persistedDocumentHash.split('/');
128+
const [name, version] = operation.persistedDocumentHash.split('~');
129129
client = {
130130
name,
131131
version,
@@ -259,7 +259,7 @@ const MetadataSchema = tb.Type.Object(
259259
const PersistedDocumentHash = tb.Type.String({
260260
title: 'PersistedDocumentHash',
261261
// appName/appVersion/hash
262-
pattern: '^[a-zA-Z0-9_-]{1,64}\\/[a-zA-Z0-9._-]{1,64}\\/([A-Za-z]|[0-9]|_){1,128}$',
262+
pattern: '^[a-zA-Z0-9_-]{1,64}~[a-zA-Z0-9._-]{1,64}~([A-Za-z]|[0-9]|_){1,128}$',
263263
});
264264

265265
/** Query + Mutation */

packages/web/app/src/env/frontend.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function buildConfig() {
167167
nodeEnv: base.NODE_ENV,
168168
graphql: {
169169
persistedOperationsPrefix:
170-
base.GRAPHQL_PERSISTED_OPERATIONS === '1' ? `hive-app/${base.RELEASE}/` : null,
170+
base.GRAPHQL_PERSISTED_OPERATIONS === '1' ? `hive-app~${base.RELEASE}~` : null,
171171
},
172172
zendeskSupport: base.ZENDESK_SUPPORT === '1',
173173
migrations: {

packages/web/docs/src/pages/docs/features/app-deployments.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ Content-Type: application/json
335335
curl \
336336
-X POST \
337337
-H 'Content-Type: application/json' \
338-
-d '{"documentId": "<app_name>/<app_version>/<document_hash>"}' \
338+
-d '{"documentId": "<app_name>~<app_version>~<document_hash>"}' \
339339
http://localhost:4000/graphql
340340
```
341341

packages/web/docs/src/pages/docs/specs/usage-reports.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export interface Metadata {
161161
"persistedDocumentHash": {
162162
"type": "string",
163163
"title": "PersistedDocumentHash",
164-
"pattern": "^[a-zA-Z0-9_-]{1,64}\\/[a-zA-Z0-9._-]{1,64}\\/([A-Za-z]|[0-9]|_){1,128}$"
164+
"pattern": "^[a-zA-Z0-9_-]{1,64}~[a-zA-Z0-9._-]{1,64}~([A-Za-z]|[0-9]|_){1,128}$"
165165
}
166166
},
167167
"required": ["timestamp", "operationMapKey", "execution"]

0 commit comments

Comments
 (0)