@graphql-yoga/plugin-apq 3.0.0 → 3.0.1-alpha-20231024101107-43ee819b
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 +3 -0
- package/typings/index.d.ts +3 -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, resultConfig = {} } = 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: resultConfig.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: resultConfig.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, resultConfig = {} } = 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: resultConfig.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: resultConfig.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,9 @@ export interface APQOptions {
|
|
|
14
14
|
crypto: Crypto;
|
|
15
15
|
TextEncoder: typeof TextEncoder;
|
|
16
16
|
}) => PromiseOrValue<string>;
|
|
17
|
+
resultConfig?: {
|
|
18
|
+
forceStatusCodeOk?: boolean;
|
|
19
|
+
};
|
|
17
20
|
}
|
|
18
21
|
export interface APQStore {
|
|
19
22
|
get(key: string): PromiseOrValue<string | null | undefined>;
|
package/typings/index.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ export interface APQOptions {
|
|
|
14
14
|
crypto: Crypto;
|
|
15
15
|
TextEncoder: typeof TextEncoder;
|
|
16
16
|
}) => PromiseOrValue<string>;
|
|
17
|
+
resultConfig?: {
|
|
18
|
+
forceStatusCodeOk?: boolean;
|
|
19
|
+
};
|
|
17
20
|
}
|
|
18
21
|
export interface APQStore {
|
|
19
22
|
get(key: string): PromiseOrValue<string | null | undefined>;
|