@graphql-yoga/plugin-apq 3.0.0 → 3.0.1-alpha-20231024102755-6edc7f08
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +3 -3
- package/esm/index.js +3 -3
- package/package.json +1 -1
- package/typings/index.d.cts +7 -0
- package/typings/index.d.ts +7 -0
package/cjs/index.js
CHANGED
|
@@ -36,7 +36,7 @@ function decodeAPQExtension(input) {
|
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
38
|
function useAPQ(options = {}) {
|
|
39
|
-
const { store = createInMemoryAPQStore(), hash = hashSHA256 } = options;
|
|
39
|
+
const { store = createInMemoryAPQStore(), hash = hashSHA256, responseConfig = {} } = options;
|
|
40
40
|
return {
|
|
41
41
|
async onParams({ params, setParams, fetchAPI }) {
|
|
42
42
|
const persistedQueryData = decodeAPQExtension(params.extensions?.persistedQuery);
|
|
@@ -49,7 +49,7 @@ function useAPQ(options = {}) {
|
|
|
49
49
|
throw (0, graphql_yoga_1.createGraphQLError)('PersistedQueryNotFound', {
|
|
50
50
|
extensions: {
|
|
51
51
|
http: {
|
|
52
|
-
status: 404,
|
|
52
|
+
status: responseConfig.forceStatusCodeOk ? 200 : 404,
|
|
53
53
|
},
|
|
54
54
|
code: 'PERSISTED_QUERY_NOT_FOUND',
|
|
55
55
|
},
|
|
@@ -66,7 +66,7 @@ function useAPQ(options = {}) {
|
|
|
66
66
|
throw (0, graphql_yoga_1.createGraphQLError)('PersistedQueryMismatch', {
|
|
67
67
|
extensions: {
|
|
68
68
|
http: {
|
|
69
|
-
status: 400,
|
|
69
|
+
status: responseConfig.forceStatusCodeOk ? 200 : 400,
|
|
70
70
|
},
|
|
71
71
|
code: 'PERSISTED_QUERY_MISMATCH',
|
|
72
72
|
},
|
package/esm/index.js
CHANGED
|
@@ -31,7 +31,7 @@ function decodeAPQExtension(input) {
|
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
33
|
export function useAPQ(options = {}) {
|
|
34
|
-
const { store = createInMemoryAPQStore(), hash = hashSHA256 } = options;
|
|
34
|
+
const { store = createInMemoryAPQStore(), hash = hashSHA256, responseConfig = {} } = options;
|
|
35
35
|
return {
|
|
36
36
|
async onParams({ params, setParams, fetchAPI }) {
|
|
37
37
|
const persistedQueryData = decodeAPQExtension(params.extensions?.persistedQuery);
|
|
@@ -44,7 +44,7 @@ export function useAPQ(options = {}) {
|
|
|
44
44
|
throw createGraphQLError('PersistedQueryNotFound', {
|
|
45
45
|
extensions: {
|
|
46
46
|
http: {
|
|
47
|
-
status: 404,
|
|
47
|
+
status: responseConfig.forceStatusCodeOk ? 200 : 404,
|
|
48
48
|
},
|
|
49
49
|
code: 'PERSISTED_QUERY_NOT_FOUND',
|
|
50
50
|
},
|
|
@@ -61,7 +61,7 @@ export function useAPQ(options = {}) {
|
|
|
61
61
|
throw createGraphQLError('PersistedQueryMismatch', {
|
|
62
62
|
extensions: {
|
|
63
63
|
http: {
|
|
64
|
-
status: 400,
|
|
64
|
+
status: responseConfig.forceStatusCodeOk ? 200 : 400,
|
|
65
65
|
},
|
|
66
66
|
code: 'PERSISTED_QUERY_MISMATCH',
|
|
67
67
|
},
|
package/package.json
CHANGED
package/typings/index.d.cts
CHANGED
|
@@ -14,6 +14,13 @@ export interface APQOptions {
|
|
|
14
14
|
crypto: Crypto;
|
|
15
15
|
TextEncoder: typeof TextEncoder;
|
|
16
16
|
}) => PromiseOrValue<string>;
|
|
17
|
+
responseConfig?: {
|
|
18
|
+
/**
|
|
19
|
+
* If true, the status code of the response (if the query
|
|
20
|
+
* is not found or mismatched) will be 200.
|
|
21
|
+
*/
|
|
22
|
+
forceStatusCodeOk?: boolean;
|
|
23
|
+
};
|
|
17
24
|
}
|
|
18
25
|
export interface APQStore {
|
|
19
26
|
get(key: string): PromiseOrValue<string | null | undefined>;
|
package/typings/index.d.ts
CHANGED
|
@@ -14,6 +14,13 @@ export interface APQOptions {
|
|
|
14
14
|
crypto: Crypto;
|
|
15
15
|
TextEncoder: typeof TextEncoder;
|
|
16
16
|
}) => PromiseOrValue<string>;
|
|
17
|
+
responseConfig?: {
|
|
18
|
+
/**
|
|
19
|
+
* If true, the status code of the response (if the query
|
|
20
|
+
* is not found or mismatched) will be 200.
|
|
21
|
+
*/
|
|
22
|
+
forceStatusCodeOk?: boolean;
|
|
23
|
+
};
|
|
17
24
|
}
|
|
18
25
|
export interface APQStore {
|
|
19
26
|
get(key: string): PromiseOrValue<string | null | undefined>;
|