INNER CODE UNIT · TypeScript

batchPlugin

logaretm/villus · packages/batch/src/index.ts:34

  return definePlugin(function batchPlugin(ctx) {
    const { useResult, opContext, operation } = ctx;

    if (opts?.exclude?.(ctx.operation, ctx)) {
      return fetchPluginInstance(ctx);
    }

    async function consume() {
      const pending = operations;
      const body = `[${operations.map(o => o.body).join(',')}]`;
      const fetchOpts = mergeFetchOpts(opContext, { headers: {}, body });
      operations = [];

      if (!fetch) {
        throw new Error('Could not resolve fetch, please provide a fetch function');
      }

      let response: ParsedResponse<unknown>;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…