1 | export const serializerMiddleware = (options, serializer) => (next, context) => async (args) => {
|
2 | const endpoint = context.endpointV2?.url && options.urlParser
|
3 | ? async () => options.urlParser(context.endpointV2.url)
|
4 | : options.endpoint;
|
5 | if (!endpoint) {
|
6 | throw new Error("No valid endpoint provider available.");
|
7 | }
|
8 | const request = await serializer(args.input, { ...options, endpoint });
|
9 | return next({
|
10 | ...args,
|
11 | request,
|
12 | });
|
13 | };
|