diff --git a/integration-tests/tests/api/app-deployments.spec.ts b/integration-tests/tests/api/app-deployments.spec.ts index 540c81c336..c4625bfec4 100644 --- a/integration-tests/tests/api/app-deployments.spec.ts +++ b/integration-tests/tests/api/app-deployments.spec.ts @@ -1858,7 +1858,7 @@ test('app deployment usage reporting', async () => { contextValue: { request }, }, {}, - 'app-name/app-version/aaa', + 'app-name~app-version~aaa', ); await waitFor(5000); diff --git a/packages/libraries/apollo/tests/persisted-documents.spec.ts b/packages/libraries/apollo/tests/persisted-documents.spec.ts index 21957a3592..2022d3315a 100644 --- a/packages/libraries/apollo/tests/persisted-documents.spec.ts +++ b/packages/libraries/apollo/tests/persisted-documents.spec.ts @@ -57,7 +57,7 @@ test('use persisted documents (GraphQL over HTTP "documentId")', async () => { 'Content-Type': 'application/json', }, body: JSON.stringify({ - documentId: 'client-name/client-version/hash', + documentId: 'client-name~client-version~hash', }), }); expect(response.status).toBe(200); @@ -112,7 +112,7 @@ test('persisted document not found (GraphQL over HTTP "documentId")', async () = 'Content-Type': 'application/json', }, body: JSON.stringify({ - documentId: 'client-name/client-version/hash', + documentId: 'client-name~client-version~hash', }), }); @@ -265,7 +265,7 @@ test('usage reporting for persisted document', async () => { { metadata: {}, operationMapKey: 'ace78a32bbf8a79071356e5d5b13c5c83baf4e14', - persistedDocumentHash: 'client-name/client-version/hash', + persistedDocumentHash: 'client-name~client-version~hash', }, ]); @@ -334,7 +334,7 @@ test('usage reporting for persisted document', async () => { 'Content-Type': 'application/json', }, body: JSON.stringify({ - documentId: 'client-name/client-version/hash', + documentId: 'client-name~client-version~hash', }), }); expect(response.status).toBe(200); diff --git a/packages/libraries/core/src/client/persisted-documents.ts b/packages/libraries/core/src/client/persisted-documents.ts index 597d2ef295..bde3d003fa 100644 --- a/packages/libraries/core/src/client/persisted-documents.ts +++ b/packages/libraries/core/src/client/persisted-documents.ts @@ -32,7 +32,9 @@ export function createPersistedDocuments(config: PersistedDocumentsConfiguration return document; } - const response = await fetch(config.cdn.endpoint + '/apps/' + documentId, { + const cdnHttpId = documentId.replaceAll('~', '/'); + + const response = await fetch(config.cdn.endpoint + '/apps/' + cdnHttpId, { method: 'GET', headers: { 'X-Hive-CDN-Key': config.cdn.accessToken, diff --git a/packages/libraries/yoga/tests/persisted-documents.spec.ts b/packages/libraries/yoga/tests/persisted-documents.spec.ts index 3145c7d184..c8f351251d 100644 --- a/packages/libraries/yoga/tests/persisted-documents.spec.ts +++ b/packages/libraries/yoga/tests/persisted-documents.spec.ts @@ -47,7 +47,7 @@ test('use persisted documents (GraphQL over HTTP "documentId")', async () => { 'Content-Type': 'application/json', }, body: JSON.stringify({ - documentId: 'client-name/client-version/hash', + documentId: 'client-name~client-version~hash', }), }); @@ -103,7 +103,7 @@ test('use persisted documents (GraphQL over HTTP "documentId") real thing', asyn 'Content-Type': 'application/json', }, body: JSON.stringify({ - documentId: 'client-name/client-version/hash', + documentId: 'client-name~client-version~hash', }), }); @@ -152,7 +152,7 @@ test('persisted document not found (GraphQL over HTTP "documentId")', async () = 'Content-Type': 'application/json', }, body: JSON.stringify({ - documentId: 'client-name/client-version/hash', + documentId: 'client-name~client-version~hash', }), }); @@ -308,7 +308,7 @@ test('use persisted documents for subscription (GraphQL over HTTP "documentId")' Accept: 'text/event-stream', }, body: JSON.stringify({ - documentId: 'client-name/client-version/hash', + documentId: 'client-name~client-version~hash', }), }); @@ -363,7 +363,7 @@ test('usage reporting for persisted document', async () => { { metadata: {}, operationMapKey: 'ace78a32bbf8a79071356e5d5b13c5c83baf4e14', - persistedDocumentHash: 'client-name/client-version/hash', + persistedDocumentHash: 'client-name~client-version~hash', }, ]); @@ -427,7 +427,7 @@ test('usage reporting for persisted document', async () => { 'Content-Type': 'application/json', }, body: JSON.stringify({ - documentId: 'client-name/client-version/hash', + documentId: 'client-name~client-version~hash', }), }); expect(response.status).toBe(200); @@ -476,7 +476,7 @@ test('usage reporting for persisted document (subscription)', async () => { { metadata: {}, operationMapKey: '74cf03b67c3846231d04927b02e1fca45e727223', - persistedDocumentHash: 'client-name/client-version/hash', + persistedDocumentHash: 'client-name~client-version~hash', }, ]); @@ -553,7 +553,7 @@ test('usage reporting for persisted document (subscription)', async () => { Accept: 'text/event-stream', }, body: JSON.stringify({ - documentId: 'client-name/client-version/hash', + documentId: 'client-name~client-version~hash', }), }); expect(response.status).toBe(200); diff --git a/packages/services/usage/src/usage-processor-2.ts b/packages/services/usage/src/usage-processor-2.ts index f9ce1c8c7f..50d8bce265 100644 --- a/packages/services/usage/src/usage-processor-2.ts +++ b/packages/services/usage/src/usage-processor-2.ts @@ -125,7 +125,7 @@ export function usageProcessorV2( let client: ClientMetadata | undefined; if (operation.persistedDocumentHash) { - const [name, version] = operation.persistedDocumentHash.split('/'); + const [name, version] = operation.persistedDocumentHash.split('~'); client = { name, version, @@ -259,7 +259,7 @@ const MetadataSchema = tb.Type.Object( const PersistedDocumentHash = tb.Type.String({ title: 'PersistedDocumentHash', // appName/appVersion/hash - pattern: '^[a-zA-Z0-9_-]{1,64}\\/[a-zA-Z0-9._-]{1,64}\\/([A-Za-z]|[0-9]|_){1,128}$', + pattern: '^[a-zA-Z0-9_-]{1,64}~[a-zA-Z0-9._-]{1,64}~([A-Za-z]|[0-9]|_){1,128}$', }); /** Query + Mutation */ diff --git a/packages/web/app/src/env/frontend.ts b/packages/web/app/src/env/frontend.ts index 073b3b783e..941ff48b8a 100644 --- a/packages/web/app/src/env/frontend.ts +++ b/packages/web/app/src/env/frontend.ts @@ -167,7 +167,7 @@ function buildConfig() { nodeEnv: base.NODE_ENV, graphql: { persistedOperationsPrefix: - base.GRAPHQL_PERSISTED_OPERATIONS === '1' ? `hive-app/${base.RELEASE}/` : null, + base.GRAPHQL_PERSISTED_OPERATIONS === '1' ? `hive-app~${base.RELEASE}~` : null, }, zendeskSupport: base.ZENDESK_SUPPORT === '1', migrations: { diff --git a/packages/web/docs/src/pages/docs/features/app-deployments.mdx b/packages/web/docs/src/pages/docs/features/app-deployments.mdx index cc355700aa..dbe48c2d3a 100644 --- a/packages/web/docs/src/pages/docs/features/app-deployments.mdx +++ b/packages/web/docs/src/pages/docs/features/app-deployments.mdx @@ -335,7 +335,7 @@ Content-Type: application/json curl \ -X POST \ -H 'Content-Type: application/json' \ - -d '{"documentId": "//"}' \ + -d '{"documentId": "~~"}' \ http://localhost:4000/graphql ``` diff --git a/packages/web/docs/src/pages/docs/specs/usage-reports.md b/packages/web/docs/src/pages/docs/specs/usage-reports.md index f1cd0edd4c..0659043922 100644 --- a/packages/web/docs/src/pages/docs/specs/usage-reports.md +++ b/packages/web/docs/src/pages/docs/specs/usage-reports.md @@ -161,7 +161,7 @@ export interface Metadata { "persistedDocumentHash": { "type": "string", "title": "PersistedDocumentHash", - "pattern": "^[a-zA-Z0-9_-]{1,64}\\/[a-zA-Z0-9._-]{1,64}\\/([A-Za-z]|[0-9]|_){1,128}$" + "pattern": "^[a-zA-Z0-9_-]{1,64}~[a-zA-Z0-9._-]{1,64}~([A-Za-z]|[0-9]|_){1,128}$" } }, "required": ["timestamp", "operationMapKey", "execution"]