INNER CODE UNIT · TypeScript

withContext

apollographql/apollo-link · packages/apollo-link-context/src/__tests__/index.ts:132

  const withContext = setContext((_, { count }) =>
    sleep(1).then(() => ({ count: count + 1 })),
  );

  const mockLink = new ApolloLink(operation => {
    const { count } = operation.getContext();
    expect(count).toEqual(2);
    return Observable.of({ data });
  });

  const link = withContext.concat(mockLink);

  execute(link, { query, context: { count: 1 } }).subscribe(result => {
    expect(result.data).toEqual(data);
    done();
  });
});

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…