Skip to content

Conversation

@EmrysMyrddin
Copy link
Collaborator

Description

Add a new extension to graphql errors to easily locate the source of error in schema.

This information can be useful to create metrics and point out field in schema with hight rates of errors.

This feature is needed in the context of the new Console Tracing feature.

Type of change

  • New feature (non-breaking change which adds functionality)

@changeset-bot
Copy link

changeset-bot bot commented Oct 14, 2025

⚠️ No Changeset found

Latest commit: 4f4405b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

theguild-bot and others added 5 commits October 14, 2025 17:28
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Bumps the actions-deps group with 1 update: [webpack](https://github.com/webpack/webpack).


Updates `webpack` from 5.99.1 to 5.99.2
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](webpack/webpack@v5.99.1...v5.99.2)

---
updated-dependencies:
- dependency-name: webpack
  dependency-version: 5.99.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions-deps
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Bumps [next](https://github.com/vercel/next.js) from 15.4.2 to 15.4.3.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](vercel/next.js@v15.4.2...v15.4.3)

---
updated-dependencies:
- dependency-name: next
  dependency-version: 15.4.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@EmrysMyrddin EmrysMyrddin force-pushed the feat/executor/error-schema-coordinates branch from 42bb1f4 to 78dd816 Compare October 14, 2025 15:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features
    • Added optional configuration flag to enable schema coordinates in GraphQL error extensions, enriching error information with field-level and type details. When activated, errors include enhanced context that helps developers quickly identify error sources, improve observability, and streamline debugging of GraphQL operations.

Walkthrough

This change introduces support for including GraphQL field schema coordinates in error extensions. It adds a new schemaCoordinateInErrors flag that flows through the execution context, enabling the locatedError function to conditionally attach schema coordinate information to errors for improved observability.

Changes

Cohort / File(s) Summary
Error handling utilities
packages/utils/src/errors.ts
Imports GraphQL's locatedError as _locatedError, wraps it in a new public locatedError function that conditionally attaches schema coordinates to error extensions. Introduces SchemaCoordinateInfo type and ERROR_EXTENSION_SCHEMA_COORDINATE symbol. Updated relocatedError signature to accept optional info parameter.
Executor execution context
packages/executor/src/execution/execute.ts
Adds schemaCoordinateInErrors?: boolean to ExecutionContext and ExecutionArgs. Updates buildExecutionContext to pass through this flag. Wires info parameter into numerous locatedError calls across field execution, streaming, subscriptions, and error coercion paths when flag is enabled.
Executor and request types
packages/executor/src/execution/normalizedExecutor.ts, packages/utils/src/Interfaces.ts
Adds schemaCoordinateInErrors?: boolean field to ExecutionRequest interface with JSDoc. Updates executorFromSchema to propagate this field through the execution request payload.

Sequence Diagram

sequenceDiagram
    participant Executor
    participant ExecContext
    participant ErrorHandler
    participant Extensions

    rect rgb(240, 248, 255)
    note over Executor: schemaCoordinateInErrors enabled
    Executor->>ExecContext: execute(query, schema, ..., {schemaCoordinateInErrors: true})
    ExecContext->>ExecContext: buildExecutionContext() includes flag
    end

    rect rgb(255, 250, 240)
    note over Executor: Error occurs during execution
    Executor->>ErrorHandler: locatedError(rawError, nodes, path, info)
    end

    rect rgb(240, 255, 240)
    note over ErrorHandler: Conditionally enrich error
    alt info provided & flag enabled
        ErrorHandler->>Extensions: Attach schema coordinate to extensions
        Extensions-->>ErrorHandler: Enhanced error
    else info not provided or flag disabled
        ErrorHandler-->>ErrorHandler: Return error as-is
    end
    end

    ErrorHandler-->>Executor: GraphQLError with optional schema coordinate
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The changes follow a consistent pattern of wiring a new parameter through multiple execution paths and error handlers. While there's moderate logic density in understanding how schema coordinates are conditionally attached, the changes are largely homogeneous (repeated parameter passing and conditional info attachment). The scope spans multiple files but affects primarily error-handling and context-propagation paths with clear intent.

Possibly related PRs

Suggested reviewers

  • enisdenjo

Poem

🐰 A hopping fix for errors bright,
With coordinates now in sight,
Through execution's winding way,
Schema hints illuminate the day!
Debugging dreams come true so right.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly reflects the main change by indicating the addition of a schema coordinates extension to GraphQL errors within the executor. It accurately describes the feature focus without extraneous details, using concise phrasing and appropriate scope. This aligns with the changes to propagate schemaCoordinateInErrors flags and augment error creation. Therefore, it meets the criteria for a clear and relevant pull request title.
Description Check ✅ Passed The description clearly outlines adding a new extension to GraphQL errors to locate schema sources and mentions its use for metrics and console tracing. It directly relates to the code changes that introduce schemaCoordinateInErrors and the locatedError enhancements. While not overly detailed, it conveys the purpose and context of the feature. Hence, it passes the description check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/executor/error-schema-coordinates

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

💻 Website Preview

The latest changes are available as preview in: https://pr-7588.graphql-tools.pages.dev

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 524aeb1 and 78dd816.

📒 Files selected for processing (3)
  • packages/executor/src/execution/execute.ts (10 hunks)
  • packages/executor/src/execution/locatedError.ts (1 hunks)
  • packages/utils/src/errors.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
packages/executor/src/execution/locatedError.ts (2)
packages/utils/src/types.ts (1)
  • Maybe (29-29)
packages/utils/src/Interfaces.ts (1)
  • GraphQLResolveInfo (71-73)
packages/utils/src/errors.ts (2)
packages/utils/src/types.ts (1)
  • Maybe (29-29)
packages/utils/src/Interfaces.ts (1)
  • GraphQLResolveInfo (71-73)
packages/executor/src/execution/execute.ts (3)
packages/executor/src/execution/locatedError.ts (1)
  • locatedError (5-14)
packages/utils/src/Path.ts (1)
  • pathToArray (23-31)
packages/executor/src/execution/coerceError.ts (1)
  • coerceError (1-24)
🪛 GitHub Check: Type Check on GraphQL v15
packages/executor/src/execution/locatedError.ts

[failure] 11-11:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

🪛 GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v15
packages/executor/src/execution/locatedError.ts

[failure] 11-11:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Unit Test on Node 24 (ubuntu-latest) and GraphQL v16
  • GitHub Check: Unit Test on Node 22 (ubuntu-latest) and GraphQL v16
  • GitHub Check: deployment
  • GitHub Check: Unit Test on Bun
  • GitHub Check: Unit Test on Node 18 (windows-latest) and GraphQL v16
  • GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v16
🔇 Additional comments (9)
packages/utils/src/errors.ts (3)

2-2: LGTM: Import statement is correct.

The import of GraphQLResolveInfo from the local Interfaces module is appropriate for the new parameter.


64-68: LGTM: Backward-compatible signature change.

The addition of the optional info parameter maintains backward compatibility with existing callers while enabling schema coordinate enrichment.


75-80: Ignore null-safety concerns for info.parentType and info.fieldName. Both are required properties of GraphQLResolveInfo and thus always defined when info is present.

Likely an incorrect or invalid review comment.

packages/executor/src/execution/locatedError.ts (1)

5-14: Verify null safety for info properties.

Similar to the concern in errors.ts, ensure that info.parentType and info.fieldName are always defined when called, as there are no null checks before accessing these properties.

Based on learnings from the GraphQL specification, GraphQLResolveInfo should always have parentType and fieldName defined during field resolution. However, confirm this by reviewing the interface definition.

packages/executor/src/execution/execute.ts (5)

60-60: LGTM: Import correctly switched to local wrapper.

The import now uses the local locatedError wrapper that enriches errors with schema coordinates instead of the graphql-js version.


749-749: LGTM: Consistent error enrichment in executeField.

All error handling paths in executeField now pass the info parameter to enable schema coordinate enrichment. The info variable is correctly defined at line 707 and is available in all these error handling blocks.

Also applies to: 756-756, 768-768, 775-775


1044-1044: LGTM: Consistent error enrichment in list completion.

Error handling paths in completeAsyncIteratorValue and completeListItemValue correctly pass the info parameter, which is available in scope from the function parameters.

Also applies to: 1204-1204, 1217-1217


1792-1792: LGTM: Consistent error enrichment in subscription execution.

Subscription error handling at lines 1792 and 1798 correctly passes the info parameter, which is defined at line 1768.

Also applies to: 1798-1798


1924-1924: LGTM: Consistent error enrichment in stream execution.

All stream-related error handling paths correctly pass the info parameter, which is available from function parameters in executeStreamField and executeStreamIteratorItem.

Also applies to: 1932-1932, 1980-1980, 1999-1999, 2007-2007

path: Maybe<ReadonlyArray<string | number>>,
info: GraphQLResolveInfo,
) {
const error = _locatedError(rawError, nodes, path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix type incompatibility: null handling for nodes parameter.

The static analysis correctly identifies that nodes accepts null but the upstream _locatedError expects ASTNode | ReadonlyArray<ASTNode> | undefined. You need to handle the null case explicitly.

Apply this diff to fix the type mismatch:

   const error = _locatedError(rawError, nodes, path);
+  const error = _locatedError(rawError, nodes ?? undefined, path);

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Check: Type Check on GraphQL v15

[failure] 11-11:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

🪛 GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v15

[failure] 11-11:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

🤖 Prompt for AI Agents
In packages/executor/src/execution/locatedError.ts around line 11, the call to
_locatedError(rawError, nodes, path) passes nodes which can be null while
_locatedError expects ASTNode | ReadonlyArray<ASTNode> | undefined; change the
call to explicitly handle the null case by passing undefined when nodes is null
(e.g., use a null-coalescing or conditional expression) so the argument type
matches the upstream function signature.

info: GraphQLResolveInfo,
) {
const error = _locatedError(rawError, nodes, path);
error.extensions['schemaCoordinates'] = `${info.parentType.name}.${info.fieldName}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Initialize extensions if undefined to prevent runtime errors.

Direct assignment to error.extensions['schemaCoordinates'] will fail if extensions is undefined. The GraphQL error object should have extensions initialized, but it's safer to ensure it exists.

Apply this diff to safely initialize extensions:

-  error.extensions['schemaCoordinates'] = `${info.parentType.name}.${info.fieldName}`;
+  if (!error.extensions) {
+    error.extensions = {};
+  }
+  error.extensions['schemaCoordinates'] = `${info.parentType.name}.${info.fieldName}`;

Alternatively, use a more concise approach:

-  error.extensions['schemaCoordinates'] = `${info.parentType.name}.${info.fieldName}`;
+  error.extensions = {
+    ...error.extensions,
+    schemaCoordinates: `${info.parentType.name}.${info.fieldName}`,
+  };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
error.extensions['schemaCoordinates'] = `${info.parentType.name}.${info.fieldName}`;
if (!error.extensions) {
error.extensions = {};
}
error.extensions['schemaCoordinates'] = `${info.parentType.name}.${info.fieldName}`;
🤖 Prompt for AI Agents
In packages/executor/src/execution/locatedError.ts around line 12, the code
assigns to error.extensions['schemaCoordinates'] without ensuring extensions is
defined; update the code to first ensure error.extensions is an object (create
an empty object when undefined) and then set the schemaCoordinates property on
it so the assignment cannot throw when extensions is missing.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 524aeb1 and 78dd816.

📒 Files selected for processing (3)
  • packages/executor/src/execution/execute.ts (10 hunks)
  • packages/executor/src/execution/locatedError.ts (1 hunks)
  • packages/utils/src/errors.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
packages/executor/src/execution/execute.ts (3)
packages/executor/src/execution/locatedError.ts (1)
  • locatedError (5-14)
packages/utils/src/Path.ts (1)
  • pathToArray (23-31)
packages/executor/src/execution/coerceError.ts (1)
  • coerceError (1-24)
packages/executor/src/execution/locatedError.ts (2)
packages/utils/src/types.ts (1)
  • Maybe (29-29)
packages/utils/src/Interfaces.ts (1)
  • GraphQLResolveInfo (71-73)
packages/utils/src/errors.ts (2)
packages/utils/src/types.ts (1)
  • Maybe (29-29)
packages/utils/src/Interfaces.ts (1)
  • GraphQLResolveInfo (71-73)
🪛 GitHub Check: Type Check on GraphQL v15
packages/executor/src/execution/locatedError.ts

[failure] 11-11:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

🪛 GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v15
packages/executor/src/execution/locatedError.ts

[failure] 11-11:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: alpha / snapshot
  • GitHub Check: Unit Test on Node 24 (ubuntu-latest) and GraphQL v16
  • GitHub Check: Unit Test on Node 22 (ubuntu-latest) and GraphQL v16
  • GitHub Check: deployment
  • GitHub Check: Unit Test on Bun
  • GitHub Check: Unit Test on Node 18 (windows-latest) and GraphQL v16
  • GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v16
  • GitHub Check: Full Check on GraphQL v16
🔇 Additional comments (3)
packages/executor/src/execution/execute.ts (2)

60-60: Import of wrapper is correct

Using the local locatedError wrapper centralizes augmentation. No issues.


745-757: Good adoption of locatedError(info) across error paths

Passing info enables consistent schemaCoordinates enrichment. The changes keep original control flow intact.

Also applies to: 756-760, 768-776, 775-779, 1044-1046, 1202-1209, 1216-1221, 1792-1793, 1798-1799, 1924-1935, 1980-1984

packages/utils/src/errors.ts (1)

2-2: Non‑breaking extension to relocatedError(info) looks good

Signature change is backward‑compatible; extensions merge preserves existing keys and adds schemaCoordinates when info is provided. Fits createGraphQLError across graphql v15/v16/v17.

Also applies to: 64-81

Comment on lines 1 to 14
import type { ASTNode } from 'graphql';
import { locatedError as _locatedError } from 'graphql/error/locatedError';
import { GraphQLResolveInfo, Maybe } from '@graphql-tools/utils';

export function locatedError(
rawError: unknown,
nodes: ASTNode | ReadonlyArray<ASTNode> | null | undefined,
path: Maybe<ReadonlyArray<string | number>>,
info: GraphQLResolveInfo,
) {
const error = _locatedError(rawError, nodes, path);
error.extensions['schemaCoordinates'] = `${info.parentType.name}.${info.fieldName}`;
return error;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix GraphQL v15 type error and ensure extensions is defined

  • TS/type check fails on GraphQL v15 because _locatedError doesn’t accept null for nodes. Normalize null → undefined.
  • On v15, GraphQLError.extensions can be undefined; mutating error.extensions[...] throws. Define extensions via defineProperty with a merged object (mirrors pattern already used in execute.ts for early errors).

Apply:

 import type { ASTNode } from 'graphql';
 import { locatedError as _locatedError } from 'graphql/error/locatedError';
-import { GraphQLResolveInfo, Maybe } from '@graphql-tools/utils';
+import type { GraphQLResolveInfo, Maybe } from '@graphql-tools/utils';
 
 export function locatedError(
   rawError: unknown,
   nodes: ASTNode | ReadonlyArray<ASTNode> | null | undefined,
   path: Maybe<ReadonlyArray<string | number>>,
   info: GraphQLResolveInfo,
 ) {
-  const error = _locatedError(rawError, nodes, path);
-  error.extensions['schemaCoordinates'] = `${info.parentType.name}.${info.fieldName}`;
-  return error;
+  // graphql@15 does not accept `null` for nodes
+  const error = _locatedError(rawError, nodes ?? undefined, path);
+  const extensions = {
+    ...(error.extensions ?? {}),
+    schemaCoordinates: `${info.parentType.name}.${info.fieldName}`,
+  };
+  Object.defineProperty(error, 'extensions', { value: extensions });
+  return error;
 }

Additionally, prefer importing types with import type to avoid runtime imports.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import type { ASTNode } from 'graphql';
import { locatedError as _locatedError } from 'graphql/error/locatedError';
import { GraphQLResolveInfo, Maybe } from '@graphql-tools/utils';
export function locatedError(
rawError: unknown,
nodes: ASTNode | ReadonlyArray<ASTNode> | null | undefined,
path: Maybe<ReadonlyArray<string | number>>,
info: GraphQLResolveInfo,
) {
const error = _locatedError(rawError, nodes, path);
error.extensions['schemaCoordinates'] = `${info.parentType.name}.${info.fieldName}`;
return error;
}
import type { ASTNode } from 'graphql';
import { locatedError as _locatedError } from 'graphql/error/locatedError';
import type { GraphQLResolveInfo, Maybe } from '@graphql-tools/utils';
export function locatedError(
rawError: unknown,
nodes: ASTNode | ReadonlyArray<ASTNode> | null | undefined,
path: Maybe<ReadonlyArray<string | number>>,
info: GraphQLResolveInfo,
) {
// graphql@15 does not accept `null` for nodes
const error = _locatedError(rawError, nodes ?? undefined, path);
const extensions = {
...(error.extensions ?? {}),
schemaCoordinates: `${info.parentType.name}.${info.fieldName}`,
};
Object.defineProperty(error, 'extensions', { value: extensions });
return error;
}
🧰 Tools
🪛 GitHub Check: Type Check on GraphQL v15

[failure] 11-11:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

🪛 GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v15

[failure] 11-11:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

🤖 Prompt for AI Agents
In packages/executor/src/execution/locatedError.ts around lines 1 to 14, fix
GraphQL v15 type and runtime issues by (1) changing the nodes argument passed to
_locatedError to convert null to undefined so the call matches v15 types, (2)
ensure error.extensions exists before mutating by using Object.defineProperty to
set extensions to a merged object of existing extensions and the new
schemaCoordinates property (mirroring the pattern in execute.ts), and (3) use
import type for any type-only imports to avoid runtime imports; update the
function to normalize nodes, compute or merge extensions safely, set
schemaCoordinates, and return the error.

@EmrysMyrddin EmrysMyrddin changed the title Feat/executor/error schema coordinates feat(executor): add schema coordinates extension to graphql errors Oct 16, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (2)
packages/utils/src/errors.ts (1)

85-109: Remove duplicate schema coordinate serialization.

The relocatedError function adds schema coordinates in two ways:

  1. As a serializable schemaCoordinates field in extensions (line 99)
  2. As a non-serializable Symbol via addSchemaCoordinateToError (line 105)

This creates inconsistency with the stated design goal of using Symbols to prevent serialization. The serializable field should be removed.

Apply this diff to use only the Symbol-based approach:

   const error = createGraphQLError(originalError.message, {
     nodes: originalError.nodes,
     source: originalError.source,
     positions: originalError.positions,
     path: path == null ? originalError.path : path,
     originalError,
-    extensions: info
-      ? {
-          ...originalError.extensions,
-          schemaCoordinates: `${info.parentType.name}.${info.fieldName}`,
-        }
-      : originalError.extensions,
+    extensions: originalError.extensions,
   });

   if (info) {
     addSchemaCoordinateToError(error, info);
   }
packages/executor/src/execution/execute.ts (1)

2062-2073: Consider coercing errors before locating for consistency.

In the executeStreamIteratorItem function, rawError is passed directly to locatedError in the promise rejection handler (line 2063), while other error paths in this file apply coerceError first. This inconsistency was also noted in a past review comment.

Apply this diff for consistency:

     if (isPromise(completedItem)) {
       completedItem = completedItem.then(undefined, rawError => {
+        rawError = coerceError(rawError);
         const error = locatedError(
           rawError,
           fieldNodes,
           pathToArray(itemPath),
           exeContext.schemaCoordinateInErrors && info,
         );

Also applies to: 2076-2081

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78dd816 and 4f4405b.

📒 Files selected for processing (4)
  • packages/executor/src/execution/execute.ts (14 hunks)
  • packages/executor/src/execution/normalizedExecutor.ts (1 hunks)
  • packages/utils/src/Interfaces.ts (1 hunks)
  • packages/utils/src/errors.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/utils/src/errors.ts (1)
packages/utils/src/types.ts (1)
  • Maybe (29-29)
packages/executor/src/execution/execute.ts (3)
packages/utils/src/errors.ts (1)
  • locatedError (70-83)
packages/utils/src/Path.ts (1)
  • pathToArray (23-31)
packages/executor/src/execution/coerceError.ts (1)
  • coerceError (1-24)
🪛 GitHub Actions: pr
packages/executor/src/execution/execute.ts

[error] 60-60: TS2307: Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Actions: website
packages/executor/src/execution/execute.ts

[error] 60-60: Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: alpha / snapshot
packages/executor/src/execution/execute.ts

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: deployment
packages/executor/src/execution/execute.ts

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Full Check on GraphQL v16
packages/executor/src/execution/execute.ts

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Type Check on GraphQL v15
packages/utils/src/errors.ts

[failure] 76-76:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

packages/executor/src/execution/execute.ts

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Unit Test on Bun
packages/executor/src/execution/execute.ts

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v15
packages/utils/src/errors.ts

[failure] 76-76:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

packages/executor/src/execution/execute.ts

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v16
packages/executor/src/execution/execute.ts

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Unit Test on Node 22 (ubuntu-latest) and GraphQL v16
packages/executor/src/execution/execute.ts

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Unit Test on Node 24 (ubuntu-latest) and GraphQL v16
packages/executor/src/execution/execute.ts

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Unit Test on Node 18 (windows-latest) and GraphQL v16
🔇 Additional comments (4)
packages/utils/src/Interfaces.ts (1)

96-102: LGTM! Clear documentation of security consideration.

The JSDoc appropriately documents the security implication of exposing schema coordinates using a Symbol to prevent serialization. This is a well-designed addition to the public API.

packages/executor/src/execution/normalizedExecutor.ts (1)

52-52: LGTM!

The flag is correctly propagated through the normalized execution path, maintaining consistency with other request fields.

packages/executor/src/execution/execute.ts (2)

130-130: LGTM! Flag correctly propagated through execution context.

The schemaCoordinateInErrors flag is properly threaded through ExecutionContext, ExecutionArgs, and buildExecutionContext, enabling conditional schema coordinate attachment to errors throughout the execution pipeline.

Also applies to: 251-251, 424-424, 537-537


753-759: Error handling pattern is consistently applied across all error paths.

All 14 locatedError calls in the file (including those at lines 753, 765, 782, 794, 1068, 1233, 1251, 1831, 1842, 1973, 1986, 2039, 2063, and 2076) use the identical conditional pattern: exeContext.schemaCoordinateInErrors && info for the 4th argument. No inconsistencies were found.

import { coerceError } from './coerceError.js';
import { flattenAsyncIterable } from './flattenAsyncIterable.js';
import { invariant } from './invariant.js';
import { locatedError } from './locatedError.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix incorrect import path causing build failures.

The import is trying to load from a non-existent file './locatedError.js'. The locatedError function is actually exported from '@graphql-tools/utils', which is already imported at the top of this file.

Apply this diff:

-import { locatedError } from './locatedError.js';

And add locatedError to the existing import from '@graphql-tools/utils' at line 30-53:

 import {
   collectSubFields as _collectSubfields,
   addPath,
   collectFields,
   createGraphQLError,
   fakePromise,
   getArgumentValues,
   getDefinedRootType,
   GraphQLResolveInfo,
   GraphQLStreamDirective,
   inspect,
   isAsyncIterable,
   isIterableObject,
   isObjectLike,
   isPromise,
+  locatedError,
   mapAsyncIterator,
   Maybe,
   MaybePromise,
   memoize1,
   memoize3,
   Path,
   pathToArray,
   promiseReduce,
 } from '@graphql-tools/utils';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { locatedError } from './locatedError.js';
// Remove this line – it references a non-existent file
// import { locatedError } from './locatedError.js';
import {
collectSubFields as _collectSubfields,
addPath,
collectFields,
createGraphQLError,
fakePromise,
getArgumentValues,
getDefinedRootType,
GraphQLResolveInfo,
GraphQLStreamDirective,
inspect,
isAsyncIterable,
isIterableObject,
isObjectLike,
isPromise,
locatedError, // ← newly imported from @graphql-tools/utils
mapAsyncIterator,
Maybe,
MaybePromise,
memoize1,
memoize3,
Path,
pathToArray,
promiseReduce,
} from '@graphql-tools/utils';
🧰 Tools
🪛 GitHub Actions: pr

[error] 60-60: TS2307: Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Actions: website

[error] 60-60: Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: alpha / snapshot

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: deployment

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Full Check on GraphQL v16

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Type Check on GraphQL v15

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Unit Test on Bun

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v15

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v16

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Unit Test on Node 22 (ubuntu-latest) and GraphQL v16

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🪛 GitHub Check: Unit Test on Node 24 (ubuntu-latest) and GraphQL v16

[failure] 60-60:
Cannot find module './locatedError.js' or its corresponding type declarations.

🤖 Prompt for AI Agents
In packages/executor/src/execution/execute.ts around line 60, the file
incorrectly imports locatedError from './locatedError.js' which doesn't exist;
instead add locatedError to the existing import list from '@graphql-tools/utils'
(the import block at ~lines 30-53) and remove the bogus './locatedError.js'
import line so the symbol is resolved from the correct package.

Comment on lines +70 to +83
export function locatedError(
rawError: unknown,
nodes: ASTNode | ReadonlyArray<ASTNode> | null | undefined,
path: Maybe<ReadonlyArray<string | number>>,
info: SchemaCoordinateInfo | false | null | undefined,
) {
const error = _locatedError(rawError, nodes, path);

if (info) {
addSchemaCoordinateToError(error, info);
}

return error;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix type incompatibility with GraphQL's locatedError.

The nodes parameter is typed as ASTNode | ReadonlyArray<ASTNode> | null | undefined, but GraphQL's locatedError function only accepts undefined (not null) according to the static analysis hints. This is causing build failures.

Apply this diff to fix the type:

 export function locatedError(
   rawError: unknown,
-  nodes: ASTNode | ReadonlyArray<ASTNode> | null | undefined,
+  nodes: ASTNode | ReadonlyArray<ASTNode> | undefined,
   path: Maybe<ReadonlyArray<string | number>>,
   info: SchemaCoordinateInfo | false | null | undefined,
 ) {
   const error = _locatedError(rawError, nodes, path);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function locatedError(
rawError: unknown,
nodes: ASTNode | ReadonlyArray<ASTNode> | null | undefined,
path: Maybe<ReadonlyArray<string | number>>,
info: SchemaCoordinateInfo | false | null | undefined,
) {
const error = _locatedError(rawError, nodes, path);
if (info) {
addSchemaCoordinateToError(error, info);
}
return error;
}
export function locatedError(
rawError: unknown,
nodes: ASTNode | ReadonlyArray<ASTNode> | undefined,
path: Maybe<ReadonlyArray<string | number>>,
info: SchemaCoordinateInfo | false | null | undefined,
) {
const error = _locatedError(rawError, nodes, path);
if (info) {
addSchemaCoordinateToError(error, info);
}
return error;
}
🧰 Tools
🪛 GitHub Check: Type Check on GraphQL v15

[failure] 76-76:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

🪛 GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v15

[failure] 76-76:
Argument of type 'ASTNode | readonly ASTNode[] | null | undefined' is not assignable to parameter of type 'ASTNode | readonly ASTNode[] | undefined'.

🤖 Prompt for AI Agents
In packages/utils/src/errors.ts around lines 70 to 83, change the nodes
parameter type to remove null so it matches GraphQL's locatedError signature
(ASTNode | ReadonlyArray<ASTNode> | undefined), and when calling _locatedError
ensure you never pass null by normalizing nodes to undefined (e.g., treat null
as undefined) before the call; keep adding schema coordinate to the returned
error as-is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants