-
Notifications
You must be signed in to change notification settings - Fork 273
Add errors property to @connect and @source #3250
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,9 @@ const URL_PATH_TEMPLATE = 'URLPathTemplate'; | |
| const JSON_SELECTION = 'JSONSelection'; | ||
| const CONNECT_HTTP = 'ConnectHTTP'; | ||
| const CONNECT_BATCH = 'ConnectBatch'; | ||
| const SOURCE_HTTP = 'SourceHTTP'; | ||
| const CONNECT_ERRORS = "ConnectErrors"; | ||
| const SOURCE_HTTP = "SourceHTTP"; | ||
| const SOURCE_ERRORS = "SourceErrors"; | ||
| const HTTP_HEADER_MAPPING = 'HTTPHeaderMapping'; | ||
|
|
||
| export class ConnectSpecDefinition extends FeatureDefinition { | ||
|
|
@@ -153,6 +155,11 @@ export class ConnectSpecDefinition extends FeatureDefinition { | |
| ConnectBatch.addField(new InputFieldDefinition('maxSize')).type = schema.intType(); | ||
| connect.addArgument('batch', ConnectBatch); | ||
|
|
||
| const ConnectErrors = schema.addType(new InputObjectType(this.typeNameInSchema(schema, CONNECT_ERRORS)!)); | ||
| ConnectErrors.addField(new InputFieldDefinition('message')).type = JSONSelection; | ||
| ConnectErrors.addField(new InputFieldDefinition('extensions')).type = JSONSelection; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand the design correctly, setting either 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the design:
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) |
||
| connect.addArgument('errors', ConnectErrors); | ||
|
|
||
| connect.addArgument('selection', new NonNullType(JSONSelection)); | ||
| connect.addArgument('entity', schema.booleanType(), false); | ||
|
|
||
|
|
@@ -191,6 +198,11 @@ export class ConnectSpecDefinition extends FeatureDefinition { | |
|
|
||
| source.addArgument('http', new NonNullType(SourceHTTP)); | ||
|
|
||
| const SourceErrors = schema.addType(new InputObjectType(this.typeNameInSchema(schema, SOURCE_ERRORS)!)); | ||
| SourceErrors.addField(new InputFieldDefinition('message')).type = JSONSelection; | ||
| SourceErrors.addField(new InputFieldDefinition('extensions')).type = JSONSelection; | ||
| source.addArgument('errors', SourceErrors); | ||
|
|
||
| return []; | ||
| } | ||
|
|
||
|
|
||
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.
Should we make this and the source one a single
ConnectorsErrorstype for simplicity since they're identical? Like how we share headers.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.
🤔 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 😅
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.
Done!