MCPcopy
hub / github.com/ardatan/graphql-tools / assertEventStream

Function assertEventStream

packages/executor/src/execution/execute.ts:1851–1883  ·  view source on GitHub ↗
(
  result: unknown,
  signal?: AbortSignal,
  onSignalAbort?: (handler: () => void) => void,
)

Source from the content-addressed store, hash-verified

1849}
1850
1851function assertEventStream(
1852 result: unknown,
1853 signal?: AbortSignal,
1854 onSignalAbort?: (handler: () => void) => void,
1855): AsyncIterable<unknown> {
1856 signal?.throwIfAborted();
1857 if (result instanceof Error) {
1858 throw result;
1859 }
1860
1861 // Assert field returned an event stream, otherwise yield an error.
1862 if (!isAsyncIterable(result)) {
1863 throw createGraphQLError(
1864 'Subscription field must return Async Iterable. ' + `Received: ${inspect(result)}.`,
1865 );
1866 }
1867 if (onSignalAbort) {
1868 return {
1869 [Symbol.asyncIterator]() {
1870 const asyncIterator = result[Symbol.asyncIterator]();
1871
1872 if (asyncIterator.return) {
1873 onSignalAbort?.(() => {
1874 asyncIterator.return?.();
1875 });
1876 }
1877
1878 return asyncIterator;
1879 },
1880 };
1881 }
1882 return result;
1883}
1884
1885function executeDeferredFragment(
1886 exeContext: ExecutionContext,

Callers 1

executeSubscriptionFunction · 0.85

Calls 3

isAsyncIterableFunction · 0.90
createGraphQLErrorFunction · 0.90
inspectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…