MCPcopy Create free account
hub / github.com/ardatan/graphql-tools / executeStreamField

Function executeStreamField

packages/executor/src/execution/execute.ts:1924–2018  ·  view source on GitHub ↗
(
  path: Path,
  itemPath: Path,
  item: MaybePromise<unknown>,
  exeContext: ExecutionContext,
  fieldNodes: Array<FieldNode>,
  info: GraphQLResolveInfo,
  itemType: GraphQLOutputType,
  label?: string,
  parentContext?: AsyncPayloadRecord,
)

Source from the content-addressed store, hash-verified

1922}
1923
1924function executeStreamField(
1925 path: Path,
1926 itemPath: Path,
1927 item: MaybePromise<unknown>,
1928 exeContext: ExecutionContext,
1929 fieldNodes: Array<FieldNode>,
1930 info: GraphQLResolveInfo,
1931 itemType: GraphQLOutputType,
1932 label?: string,
1933 parentContext?: AsyncPayloadRecord,
1934): AsyncPayloadRecord {
1935 const asyncPayloadRecord = new StreamRecord({
1936 label,
1937 path: itemPath,
1938 parentContext,
1939 exeContext,
1940 });
1941 let completedItem: MaybePromise<unknown>;
1942 try {
1943 try {
1944 if (isPromise(item)) {
1945 completedItem = item.then(resolved =>
1946 completeValue(
1947 exeContext,
1948 itemType,
1949 fieldNodes,
1950 info,
1951 itemPath,
1952 resolved,
1953 asyncPayloadRecord,
1954 ),
1955 );
1956 } else {
1957 completedItem = completeValue(
1958 exeContext,
1959 itemType,
1960 fieldNodes,
1961 info,
1962 itemPath,
1963 item,
1964 asyncPayloadRecord,
1965 );
1966 }
1967
1968 if (isPromise(completedItem)) {
1969 // Note: we don't rely on a `catch` method, but we do expect "thenable"
1970 // to take a second callback for the error case.
1971 completedItem = completedItem.then(undefined, rawError => {
1972 rawError = coerceError(rawError);
1973 const error = locatedError(
1974 rawError,
1975 fieldNodes,
1976 pathToArray(itemPath),
1977 exeContext.schemaCoordinateInErrors && info,
1978 );
1979 const handledError = handleFieldError(error, itemType, asyncPayloadRecord.errors);
1980 filterSubsequentPayloads(exeContext, itemPath, asyncPayloadRecord);
1981 return handledError;

Callers 1

completeListValueFunction · 0.85

Calls 7

addItemsMethod · 0.95
locatedErrorFunction · 0.90
pathToArrayFunction · 0.90
completeValueFunction · 0.85
coerceErrorFunction · 0.85
handleFieldErrorFunction · 0.85
filterSubsequentPayloadsFunction · 0.85

Tested by

no test coverage detected