-
-
Notifications
You must be signed in to change notification settings - Fork 832
feat(executor): add schema coordinates extension to graphql errors #7588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
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>
42bb1f4 to
78dd816
Compare
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughThis change introduces support for including GraphQL field schema coordinates in error extensions. It adds a new Changes
Sequence DiagramsequenceDiagram
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
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
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
💻 Website PreviewThe latest changes are available as preview in: https://pr-7588.graphql-tools.pages.dev |
There was a problem hiding this 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
📒 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
GraphQLResolveInfofrom the local Interfaces module is appropriate for the new parameter.
64-68: LGTM: Backward-compatible signature change.The addition of the optional
infoparameter maintains backward compatibility with existing callers while enabling schema coordinate enrichment.
75-80: Ignore null-safety concerns forinfo.parentTypeandinfo.fieldName. Both are required properties ofGraphQLResolveInfoand thus always defined wheninfois 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 thatinfo.parentTypeandinfo.fieldNameare always defined when called, as there are no null checks before accessing these properties.Based on learnings from the GraphQL specification,
GraphQLResolveInfoshould always haveparentTypeandfieldNamedefined 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
locatedErrorwrapper 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
executeFieldnow pass theinfoparameter to enable schema coordinate enrichment. Theinfovariable 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
completeAsyncIteratorValueandcompleteListItemValuecorrectly pass theinfoparameter, 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
infoparameter, 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
infoparameter, which is available from function parameters inexecuteStreamFieldandexecuteStreamIteratorItem.Also applies to: 1932-1932, 1980-1980, 1999-1999, 2007-2007
| path: Maybe<ReadonlyArray<string | number>>, | ||
| info: GraphQLResolveInfo, | ||
| ) { | ||
| const error = _locatedError(rawError, nodes, path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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}`; |
There was a problem hiding this comment.
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.
| 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.
There was a problem hiding this 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
📒 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 correctUsing the local locatedError wrapper centralizes augmentation. No issues.
745-757: Good adoption of locatedError(info) across error pathsPassing 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 goodSignature 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
| 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; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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.
There was a problem hiding this 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
relocatedErrorfunction adds schema coordinates in two ways:
- As a serializable
schemaCoordinatesfield in extensions (line 99)- 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
executeStreamIteratorItemfunction,rawErroris passed directly tolocatedErrorin the promise rejection handler (line 2063), while other error paths in this file applycoerceErrorfirst. 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
📒 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
schemaCoordinateInErrorsflag 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
locatedErrorcalls 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 && infofor 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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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.
| 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; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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.
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