@pvh-afl/graphql 1.1.13 → 1.1.14
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/dist/common/graphql-response.d.ts +96 -0
- package/dist/common/graphql-response.d.ts.map +1 -0
- package/dist/common/graphql-response.js +187 -0
- package/dist/common/graphql-response.js.map +1 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +7 -1
- package/dist/common/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { FormattedExecutionResult, GraphQLFormattedError } from 'graphql';
|
|
2
|
+
/**
|
|
3
|
+
* Root-level response envelope for GraphQL.
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS IS A `stringifyResult` FUNCTION AND NOT A PLUGIN
|
|
6
|
+
*
|
|
7
|
+
* The goal is to add `success` and `error` as SIBLINGS of `data`, leaving the
|
|
8
|
+
* operation payload exactly where it has always been:
|
|
9
|
+
*
|
|
10
|
+
* { "success": true, "error": null, "data": { "getCustomerCoupons": { ... } } }
|
|
11
|
+
*
|
|
12
|
+
* so existing consumers reading `json.data.<operation>` keep working unchanged.
|
|
13
|
+
*
|
|
14
|
+
* An Apollo plugin cannot do this. Just before serialization Apollo copies the
|
|
15
|
+
* result through a hardcoded whitelist (`orderExecutionResultFields` in
|
|
16
|
+
* runHttpQuery.js), which keeps only `errors`, `data` and `extensions` and
|
|
17
|
+
* silently drops anything else - including keys a `willSendResponse` hook added.
|
|
18
|
+
*
|
|
19
|
+
* `stringifyResult` is the one supported hook that runs AFTER that whitelist and
|
|
20
|
+
* owns the final bytes, so it is the only place a root-level key can be added.
|
|
21
|
+
*
|
|
22
|
+
* WHAT IS DROPPED
|
|
23
|
+
*
|
|
24
|
+
* The spec's `errors` array is removed. `error` replaces it, which loses:
|
|
25
|
+
*
|
|
26
|
+
* - every error after the first
|
|
27
|
+
* - `locations`, the line and column in the query text
|
|
28
|
+
*
|
|
29
|
+
* `path` survives, flattened onto `error.path`, because `data` still holds
|
|
30
|
+
* whatever resolved and a client needs to know which field did not.
|
|
31
|
+
*
|
|
32
|
+
* TRADE-OFF: the response is no longer GraphQL-spec-shaped. A spec-compliant
|
|
33
|
+
* client - Apollo Client, urql, Relay - looks for a root `errors` key, finds
|
|
34
|
+
* none, and concludes the operation succeeded. This endpoint is therefore only
|
|
35
|
+
* safe for consumers that call it as plain JSON over fetch and branch on
|
|
36
|
+
* `success`.
|
|
37
|
+
*/
|
|
38
|
+
export interface GraphqlApiError {
|
|
39
|
+
code: string;
|
|
40
|
+
message: string;
|
|
41
|
+
/**
|
|
42
|
+
* The field that failed, dotted - `checkServiceability`, `cart.lines.0.id`.
|
|
43
|
+
*
|
|
44
|
+
* Without the `errors` array this is the only way to tell which part of a
|
|
45
|
+
* multi-field query broke, which matters because `data` still holds whatever
|
|
46
|
+
* did resolve. Absent on parse and validation failures, which happen before
|
|
47
|
+
* any field is reached.
|
|
48
|
+
*/
|
|
49
|
+
path?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface WrappedGraphqlResponse {
|
|
52
|
+
/** False if the operation produced any GraphQL error. */
|
|
53
|
+
success: boolean;
|
|
54
|
+
/** The first error, flattened to `{ code, message }`. Null on success. */
|
|
55
|
+
error: GraphqlApiError | null;
|
|
56
|
+
/** Unchanged GraphQL `data` - `{ [operationName]: payload }`. */
|
|
57
|
+
data: FormattedExecutionResult['data'] | null;
|
|
58
|
+
extensions?: FormattedExecutionResult['extensions'];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Pass as `formatError` alongside `stringifyResult`.
|
|
62
|
+
*
|
|
63
|
+
* By the time a result reaches `stringifyResult` it is already formatted, and
|
|
64
|
+
* formatting discards the thrown exception - so a `ServiceUnavailableException`
|
|
65
|
+
* arrives indistinguishable from any other failure and reports as the generic
|
|
66
|
+
* `INTERNAL_ERROR`. `formatError` is the last hook that still holds the original,
|
|
67
|
+
* so it is where the two things worth keeping get copied onto `extensions`:
|
|
68
|
+
*
|
|
69
|
+
* status the HTTP status of the thrown HttpException (503, 404, ...)
|
|
70
|
+
* errorCode the `code` from a structured throw, e.g.
|
|
71
|
+
* `throw new ServiceUnavailableException({ code: 'OMS_API_FAILURE' })`
|
|
72
|
+
*
|
|
73
|
+
* Both keys are new. Nothing existing is overwritten - in particular Apollo's own
|
|
74
|
+
* `extensions.code` is left alone, so anyone reading `errors[]` today sees exactly
|
|
75
|
+
* what they see now, plus two extra fields.
|
|
76
|
+
*
|
|
77
|
+
* Errors that are not HttpExceptions pass through untouched.
|
|
78
|
+
*/
|
|
79
|
+
export declare function formatGraphqlError(formattedError: GraphQLFormattedError, error: unknown): GraphQLFormattedError;
|
|
80
|
+
/** Flattens a formatted GraphQL error to `{ code, message, path? }`. */
|
|
81
|
+
export declare function toApiError(error: GraphQLFormattedError): GraphqlApiError;
|
|
82
|
+
/** Builds the envelope. Split out from stringifying so it is unit-testable. */
|
|
83
|
+
export declare function toWrappedResponse(result: FormattedExecutionResult): WrappedGraphqlResponse;
|
|
84
|
+
/**
|
|
85
|
+
* Pass as `stringifyResult` in the app's `GraphQLModule.forRoot` config:
|
|
86
|
+
*
|
|
87
|
+
* GraphQLModule.forRoot<ApolloDriverConfig>({
|
|
88
|
+
* ...
|
|
89
|
+
* stringifyResult: wrapGraphqlResponse,
|
|
90
|
+
* })
|
|
91
|
+
*
|
|
92
|
+
* It applies to every operation in the schema at once - no resolver, service or
|
|
93
|
+
* type changes anywhere.
|
|
94
|
+
*/
|
|
95
|
+
export declare function wrapGraphqlResponse(result: FormattedExecutionResult): string;
|
|
96
|
+
//# sourceMappingURL=graphql-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-response.d.ts","sourceRoot":"","sources":["../../src/common/graphql-response.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,yDAAyD;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,0EAA0E;IAC1E,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,iEAAiE;IACjE,IAAI,EAAE,wBAAwB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC9C,UAAU,CAAC,EAAE,wBAAwB,CAAC,YAAY,CAAC,CAAC;CACrD;AAyCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,qBAAqB,EACrC,KAAK,EAAE,OAAO,GACb,qBAAqB,CAuBvB;AA6ED,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,KAAK,EAAE,qBAAqB,GAAG,eAAe,CAYxE;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,wBAAwB,GAC/B,sBAAsB,CAkBxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,CAE5E"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatGraphqlError = formatGraphqlError;
|
|
4
|
+
exports.toApiError = toApiError;
|
|
5
|
+
exports.toWrappedResponse = toWrappedResponse;
|
|
6
|
+
exports.wrapGraphqlResponse = wrapGraphqlResponse;
|
|
7
|
+
const common_1 = require("@nestjs/common");
|
|
8
|
+
/** HTTP statuses the resolvers actually throw, mapped to stable codes. */
|
|
9
|
+
const STATUS_CODES = {
|
|
10
|
+
[common_1.HttpStatus.BAD_REQUEST]: 'BAD_REQUEST',
|
|
11
|
+
[common_1.HttpStatus.UNAUTHORIZED]: 'UNAUTHORIZED',
|
|
12
|
+
[common_1.HttpStatus.FORBIDDEN]: 'FORBIDDEN',
|
|
13
|
+
[common_1.HttpStatus.NOT_FOUND]: 'NOT_FOUND',
|
|
14
|
+
[common_1.HttpStatus.CONFLICT]: 'CONFLICT',
|
|
15
|
+
[common_1.HttpStatus.UNPROCESSABLE_ENTITY]: 'UNPROCESSABLE_ENTITY',
|
|
16
|
+
[common_1.HttpStatus.TOO_MANY_REQUESTS]: 'RATE_LIMITED',
|
|
17
|
+
[common_1.HttpStatus.BAD_GATEWAY]: 'BAD_GATEWAY',
|
|
18
|
+
[common_1.HttpStatus.SERVICE_UNAVAILABLE]: 'SERVICE_UNAVAILABLE',
|
|
19
|
+
[common_1.HttpStatus.GATEWAY_TIMEOUT]: 'GATEWAY_TIMEOUT',
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Unwraps the exception a resolver actually threw.
|
|
23
|
+
*
|
|
24
|
+
* graphql-js catches the throw and re-raises it as a `GraphQLError` holding the
|
|
25
|
+
* original on `.originalError`. Apollo can add another layer of its own, so walk
|
|
26
|
+
* the chain rather than unwrapping a fixed number of times.
|
|
27
|
+
*/
|
|
28
|
+
function unwrapThrown(error) {
|
|
29
|
+
let current = error;
|
|
30
|
+
while (current !== null &&
|
|
31
|
+
typeof current === 'object' &&
|
|
32
|
+
'originalError' in current) {
|
|
33
|
+
const next = current.originalError;
|
|
34
|
+
if (next === undefined || next === null || next === current) {
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
current = next;
|
|
38
|
+
}
|
|
39
|
+
return current;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Pass as `formatError` alongside `stringifyResult`.
|
|
43
|
+
*
|
|
44
|
+
* By the time a result reaches `stringifyResult` it is already formatted, and
|
|
45
|
+
* formatting discards the thrown exception - so a `ServiceUnavailableException`
|
|
46
|
+
* arrives indistinguishable from any other failure and reports as the generic
|
|
47
|
+
* `INTERNAL_ERROR`. `formatError` is the last hook that still holds the original,
|
|
48
|
+
* so it is where the two things worth keeping get copied onto `extensions`:
|
|
49
|
+
*
|
|
50
|
+
* status the HTTP status of the thrown HttpException (503, 404, ...)
|
|
51
|
+
* errorCode the `code` from a structured throw, e.g.
|
|
52
|
+
* `throw new ServiceUnavailableException({ code: 'OMS_API_FAILURE' })`
|
|
53
|
+
*
|
|
54
|
+
* Both keys are new. Nothing existing is overwritten - in particular Apollo's own
|
|
55
|
+
* `extensions.code` is left alone, so anyone reading `errors[]` today sees exactly
|
|
56
|
+
* what they see now, plus two extra fields.
|
|
57
|
+
*
|
|
58
|
+
* Errors that are not HttpExceptions pass through untouched.
|
|
59
|
+
*/
|
|
60
|
+
function formatGraphqlError(formattedError, error) {
|
|
61
|
+
const thrown = unwrapThrown(error);
|
|
62
|
+
if (!(thrown instanceof common_1.HttpException)) {
|
|
63
|
+
return formattedError;
|
|
64
|
+
}
|
|
65
|
+
const body = thrown.getResponse();
|
|
66
|
+
const thrownCode = typeof body === 'object' &&
|
|
67
|
+
body !== null &&
|
|
68
|
+
typeof body.code === 'string'
|
|
69
|
+
? body.code
|
|
70
|
+
: undefined;
|
|
71
|
+
return {
|
|
72
|
+
...formattedError,
|
|
73
|
+
extensions: {
|
|
74
|
+
...formattedError.extensions,
|
|
75
|
+
status: thrown.getStatus(),
|
|
76
|
+
...(thrownCode ? { errorCode: thrownCode } : {}),
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Finds the HTTP status of the underlying exception.
|
|
82
|
+
*
|
|
83
|
+
* `formatGraphqlError` puts it on `extensions.status`. The other two lookups are
|
|
84
|
+
* fallbacks for a response formatted without it.
|
|
85
|
+
*/
|
|
86
|
+
function statusOf(error) {
|
|
87
|
+
const extensions = error.extensions;
|
|
88
|
+
if (!extensions) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
for (const value of [extensions.status, extensions.statusCode]) {
|
|
92
|
+
if (typeof value === 'number') {
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const original = extensions.originalError;
|
|
97
|
+
return typeof original?.statusCode === 'number'
|
|
98
|
+
? original.statusCode
|
|
99
|
+
: undefined;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Picks the most precise code available, in order:
|
|
103
|
+
*
|
|
104
|
+
* 1. the code the service itself threw - OMS_API_FAILURE, OMS_NOT_CONFIGURED
|
|
105
|
+
* 2. the status of the thrown exception - SERVICE_UNAVAILABLE, NOT_FOUND
|
|
106
|
+
* 3. Apollo's own code, which carries the reason for parse and validation
|
|
107
|
+
* failures - GRAPHQL_VALIDATION_FAILED, BAD_USER_INPUT
|
|
108
|
+
* 4. INTERNAL_ERROR
|
|
109
|
+
*
|
|
110
|
+
* 1 and 2 need `formatGraphqlError` wired as `formatError`; without it every
|
|
111
|
+
* HttpException falls to 3 and reports as INTERNAL_ERROR.
|
|
112
|
+
*
|
|
113
|
+
* A service throwing a bare `new Error(message)` can only ever reach 4. Throwing
|
|
114
|
+
* a Nest HttpException with a `code` in its body is enough to reach 1 - no schema
|
|
115
|
+
* or resolver change needed.
|
|
116
|
+
*/
|
|
117
|
+
function codeOf(error) {
|
|
118
|
+
const thrownCode = error.extensions?.errorCode;
|
|
119
|
+
if (typeof thrownCode === 'string' && thrownCode.length > 0) {
|
|
120
|
+
return thrownCode;
|
|
121
|
+
}
|
|
122
|
+
const status = statusOf(error);
|
|
123
|
+
if (status !== undefined) {
|
|
124
|
+
return STATUS_CODES[status] ?? 'INTERNAL_ERROR';
|
|
125
|
+
}
|
|
126
|
+
const code = error.extensions?.code;
|
|
127
|
+
if (typeof code === 'string' && code.length > 0) {
|
|
128
|
+
// Apollo's default for an unrecognised throw. Normalised to the code the
|
|
129
|
+
// rest of this codebase already uses.
|
|
130
|
+
return code === 'INTERNAL_SERVER_ERROR' ? 'INTERNAL_ERROR' : code;
|
|
131
|
+
}
|
|
132
|
+
return 'INTERNAL_ERROR';
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Joins the spec's `path` segments into one dotted string.
|
|
136
|
+
*
|
|
137
|
+
* The spec models it as an array mixing field names and list indices -
|
|
138
|
+
* `['cart', 'lines', 0, 'id']`. Flattened to `cart.lines.0.id` to keep the error
|
|
139
|
+
* object one level deep, matching the REST `ApiError` shape.
|
|
140
|
+
*/
|
|
141
|
+
function pathOf(error) {
|
|
142
|
+
return error.path?.length ? error.path.join('.') : undefined;
|
|
143
|
+
}
|
|
144
|
+
/** Flattens a formatted GraphQL error to `{ code, message, path? }`. */
|
|
145
|
+
function toApiError(error) {
|
|
146
|
+
const apiError = {
|
|
147
|
+
code: codeOf(error),
|
|
148
|
+
message: error.message || 'Unexpected error',
|
|
149
|
+
};
|
|
150
|
+
const path = pathOf(error);
|
|
151
|
+
if (path !== undefined) {
|
|
152
|
+
apiError.path = path;
|
|
153
|
+
}
|
|
154
|
+
return apiError;
|
|
155
|
+
}
|
|
156
|
+
/** Builds the envelope. Split out from stringifying so it is unit-testable. */
|
|
157
|
+
function toWrappedResponse(result) {
|
|
158
|
+
const { errors } = result;
|
|
159
|
+
const success = !errors || errors.length === 0;
|
|
160
|
+
const wrapped = {
|
|
161
|
+
success,
|
|
162
|
+
// A single root `success` cannot describe a query where one field resolved
|
|
163
|
+
// and another failed, so the rule is strict: any error means success:false.
|
|
164
|
+
// `data` still holds whatever did resolve.
|
|
165
|
+
error: success ? null : toApiError(errors[0]),
|
|
166
|
+
data: result.data ?? null,
|
|
167
|
+
};
|
|
168
|
+
if (result.extensions) {
|
|
169
|
+
wrapped.extensions = result.extensions;
|
|
170
|
+
}
|
|
171
|
+
return wrapped;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Pass as `stringifyResult` in the app's `GraphQLModule.forRoot` config:
|
|
175
|
+
*
|
|
176
|
+
* GraphQLModule.forRoot<ApolloDriverConfig>({
|
|
177
|
+
* ...
|
|
178
|
+
* stringifyResult: wrapGraphqlResponse,
|
|
179
|
+
* })
|
|
180
|
+
*
|
|
181
|
+
* It applies to every operation in the schema at once - no resolver, service or
|
|
182
|
+
* type changes anywhere.
|
|
183
|
+
*/
|
|
184
|
+
function wrapGraphqlResponse(result) {
|
|
185
|
+
return JSON.stringify(toWrappedResponse(result));
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=graphql-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-response.js","sourceRoot":"","sources":["../../src/common/graphql-response.ts"],"names":[],"mappings":";;AAyHA,gDA0BC;AA8ED,gCAYC;AAGD,8CAoBC;AAaD,kDAEC;AAnRD,2CAA2D;AA+D3D,0EAA0E;AAC1E,MAAM,YAAY,GAAwC;IACxD,CAAC,mBAAU,CAAC,WAAW,CAAC,EAAE,aAAa;IACvC,CAAC,mBAAU,CAAC,YAAY,CAAC,EAAE,cAAc;IACzC,CAAC,mBAAU,CAAC,SAAS,CAAC,EAAE,WAAW;IACnC,CAAC,mBAAU,CAAC,SAAS,CAAC,EAAE,WAAW;IACnC,CAAC,mBAAU,CAAC,QAAQ,CAAC,EAAE,UAAU;IACjC,CAAC,mBAAU,CAAC,oBAAoB,CAAC,EAAE,sBAAsB;IACzD,CAAC,mBAAU,CAAC,iBAAiB,CAAC,EAAE,cAAc;IAC9C,CAAC,mBAAU,CAAC,WAAW,CAAC,EAAE,aAAa;IACvC,CAAC,mBAAU,CAAC,mBAAmB,CAAC,EAAE,qBAAqB;IACvD,CAAC,mBAAU,CAAC,eAAe,CAAC,EAAE,iBAAiB;CAChD,CAAC;AAEF;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,OACE,OAAO,KAAK,IAAI;QAChB,OAAO,OAAO,KAAK,QAAQ;QAC3B,eAAe,IAAI,OAAO,EAC1B,CAAC;Q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A4B;IACrD,MAAM,QAAQ,GAAoB;QAChC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC;QACnB,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,kBAAkB;KAC7C,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,+EAA+E;AAC/E,SAAgB,iBAAiB,CAC/B,MAAgC;IAEhC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC1B,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;IAE/C,MAAM,OAAO,GAA2B;QACtC,OAAO;QACP,2EAA2E;QAC3E,4EAA4E;QAC5E,2CAA2C;QAC3C,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI;KAC1B,CAAC;IAEF,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACzC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,mBAAmB,CAAC,MAAgC;IAClE,OAAO,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
package/dist/common/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Shared types and utilities for GraphQL modules.
|
|
5
5
|
*/
|
|
6
|
+
export { wrapGraphqlResponse, formatGraphqlError, toWrappedResponse, toApiError, GraphqlApiError, WrappedGraphqlResponse, } from './graphql-response';
|
|
6
7
|
export { PageInfo } from '../product/product.types';
|
|
7
8
|
export { Image, Money, SelectedOption } from '../product/product.types';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/common/index.js
CHANGED
|
@@ -5,7 +5,13 @@
|
|
|
5
5
|
* Shared types and utilities for GraphQL modules.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.SelectedOption = exports.Money = exports.Image = exports.PageInfo = void 0;
|
|
8
|
+
exports.SelectedOption = exports.Money = exports.Image = exports.PageInfo = exports.toApiError = exports.toWrappedResponse = exports.formatGraphqlError = exports.wrapGraphqlResponse = void 0;
|
|
9
|
+
// Root-level response envelope
|
|
10
|
+
var graphql_response_1 = require("./graphql-response");
|
|
11
|
+
Object.defineProperty(exports, "wrapGraphqlResponse", { enumerable: true, get: function () { return graphql_response_1.wrapGraphqlResponse; } });
|
|
12
|
+
Object.defineProperty(exports, "formatGraphqlError", { enumerable: true, get: function () { return graphql_response_1.formatGraphqlError; } });
|
|
13
|
+
Object.defineProperty(exports, "toWrappedResponse", { enumerable: true, get: function () { return graphql_response_1.toWrappedResponse; } });
|
|
14
|
+
Object.defineProperty(exports, "toApiError", { enumerable: true, get: function () { return graphql_response_1.toApiError; } });
|
|
9
15
|
// Re-export common types from modules for convenience
|
|
10
16
|
var product_types_1 = require("../product/product.types");
|
|
11
17
|
Object.defineProperty(exports, "PageInfo", { enumerable: true, get: function () { return product_types_1.PageInfo; } });
|
package/dist/common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,sDAAsD;AACtD,0DAAoD;AAA3C,yGAAA,QAAQ,OAAA;AACjB,0DAAwE;AAA/D,sGAAA,KAAK,OAAA;AAAE,sGAAA,KAAK,OAAA;AAAE,+GAAA,cAAc,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,+BAA+B;AAC/B,uDAO4B;AAN1B,uHAAA,mBAAmB,OAAA;AACnB,sHAAA,kBAAkB,OAAA;AAClB,qHAAA,iBAAiB,OAAA;AACjB,8GAAA,UAAU,OAAA;AAKZ,sDAAsD;AACtD,0DAAoD;AAA3C,yGAAA,QAAQ,OAAA;AACjB,0DAAwE;AAA/D,sGAAA,KAAK,OAAA;AAAE,sGAAA,KAAK,OAAA;AAAE,+GAAA,cAAc,OAAA"}
|