Skip to content

Add errors property to @connect and @source#3250

Merged
andrewmcgivery merged 3 commits intonextfrom
feature/connectorstoplevelerrors
Apr 29, 2025
Merged

Add errors property to @connect and @source#3250
andrewmcgivery merged 3 commits intonextfrom
feature/connectorstoplevelerrors

Conversation

@andrewmcgivery
Copy link
Contributor

Add errors property to @connect and @source

@changeset-bot
Copy link

changeset-bot bot commented Apr 16, 2025

⚠️ No Changeset found

Latest commit: 1d0b91d

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

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Apr 16, 2025

⚠️ Docs preview not attached to branch

The preview was not built because the PR's base branch next is not in the list of sources.

An Apollo team member can comment one of the following commands to dictate which branch to attach the preview to:

  • !docs set-base-branch version-0.x
  • !docs set-base-branch main

Build ID: bf48bf40e4904fa225c4b467

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 16, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@andrewmcgivery andrewmcgivery marked this pull request as ready for review April 21, 2025 17:41
@andrewmcgivery andrewmcgivery requested a review from a team as a code owner April 21, 2025 17:41
Copy link
Contributor

@dylan-apollo dylan-apollo left a comment

Choose a reason for hiding this comment

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

Make sure you also have an open task to update the LSP definitions of this and to write some docs about it!

ConnectBatch.addField(new InputFieldDefinition('maxSize')).type = schema.intType();
connect.addArgument('batch', ConnectBatch);

const ConnectErrors = schema.addType(new InputObjectType(this.typeNameInSchema(schema, CONNECT_ERRORS)!));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make this and the source one a single ConnectorsErrors type for simplicity since they're identical? Like how we share headers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 I think the definitions should be the same. The validation in Rust is slightly different (implementation is different and variables available are different) but yea, the actual fields should be identical.

I'd have to change this in Rust too so I'll wait till you're done reviewing to actually execute this change to make sure we're still confident in it once you're done looking at both PRs 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Comment on lines +159 to +160
ConnectErrors.addField(new InputFieldDefinition('message')).type = JSONSelection;
ConnectErrors.addField(new InputFieldDefinition('extensions')).type = JSONSelection;
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand the design correctly, setting either message or extensions overrides the default behavior for both, right?

I would suggest that either we retain the default behavior when one is unset or we make these both required fields (here and in our better validations) so it's very clear to the user that they're turning off the default message (and getting an empty string??) if they set custom extensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the design:

Configuring @source(error:) or @connect(error:) overrides default or fallback values for both message and extensions, even if extensions is not set.

I interpret that as saying that that both fields are optional... but yea, I agree that it's a bit of a confusing behaviour to have one of the fields just "disappear" if not set.

So, my rust implementation allows you to override just message or extensions (or both obviously). (see: https://github.com/apollographql/router/pull/7311/files#diff-1c93268ec072033d27937077ca358823a0569f2ac1919d2976059c7a625f1fd6)

Copy link
Contributor

@dylan-apollo dylan-apollo left a comment

Choose a reason for hiding this comment

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

LGTM

@andrewmcgivery andrewmcgivery merged commit e279895 into next Apr 29, 2025
17 checks passed
@andrewmcgivery andrewmcgivery deleted the feature/connectorstoplevelerrors branch April 29, 2025 20:46
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