Skip to content

Commit dbd6428

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

File tree

8 files changed

+21
-19
lines changed

8 files changed

+21
-19
lines changed

integration-tests/tests/api/app-deployments.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,7 @@ test('app deployment usage reporting', async () => {
18581858
contextValue: { request },
18591859
},
18601860
{},
1861-
'app-name/app-version/aaa',
1861+
'app-name~app-version~aaa',
18621862
);
18631863

18641864
await waitFor(5000);

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ test('use persisted documents (GraphQL over HTTP "documentId")', async () => {
5757
'Content-Type': 'application/json',
5858
},
5959
body: JSON.stringify({
60-
documentId: 'client-name/client-version/hash',
60+
documentId: 'client-name~client-version~hash',
6161
}),
6262
});
6363
expect(response.status).toBe(200);
@@ -112,7 +112,7 @@ test('persisted document not found (GraphQL over HTTP "documentId")', async () =
112112
'Content-Type': 'application/json',
113113
},
114114
body: JSON.stringify({
115-
documentId: 'client-name/client-version/hash',
115+
documentId: 'client-name~client-version~hash',
116116
}),
117117
});
118118

@@ -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

@@ -334,7 +334,7 @@ test('usage reporting for persisted document', async () => {
334334
'Content-Type': 'application/json',
335335
},
336336
body: JSON.stringify({
337-
documentId: 'client-name/client-version/hash',
337+
documentId: 'client-name~client-version~hash',
338338
}),
339339
});
340340
expect(response.status).toBe(200);

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test('use persisted documents (GraphQL over HTTP "documentId")', async () => {
4747
'Content-Type': 'application/json',
4848
},
4949
body: JSON.stringify({
50-
documentId: 'client-name/client-version/hash',
50+
documentId: 'client-name~client-version~hash',
5151
}),
5252
});
5353

@@ -103,7 +103,7 @@ test('use persisted documents (GraphQL over HTTP "documentId") real thing', asyn
103103
'Content-Type': 'application/json',
104104
},
105105
body: JSON.stringify({
106-
documentId: 'client-name/client-version/hash',
106+
documentId: 'client-name~client-version~hash',
107107
}),
108108
});
109109

@@ -152,7 +152,7 @@ test('persisted document not found (GraphQL over HTTP "documentId")', async () =
152152
'Content-Type': 'application/json',
153153
},
154154
body: JSON.stringify({
155-
documentId: 'client-name/client-version/hash',
155+
documentId: 'client-name~client-version~hash',
156156
}),
157157
});
158158

@@ -308,7 +308,7 @@ test('use persisted documents for subscription (GraphQL over HTTP "documentId")'
308308
Accept: 'text/event-stream',
309309
},
310310
body: JSON.stringify({
311-
documentId: 'client-name/client-version/hash',
311+
documentId: 'client-name~client-version~hash',
312312
}),
313313
});
314314

@@ -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

@@ -427,7 +427,7 @@ test('usage reporting for persisted document', async () => {
427427
'Content-Type': 'application/json',
428428
},
429429
body: JSON.stringify({
430-
documentId: 'client-name/client-version/hash',
430+
documentId: 'client-name~client-version~hash',
431431
}),
432432
});
433433
expect(response.status).toBe(200);
@@ -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

@@ -553,7 +553,7 @@ test('usage reporting for persisted document (subscription)', async () => {
553553
Accept: 'text/event-stream',
554554
},
555555
body: JSON.stringify({
556-
documentId: 'client-name/client-version/hash',
556+
documentId: 'client-name~client-version~hash',
557557
}),
558558
});
559559
expect(response.status).toBe(200);

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)