diff --git a/composition-js/src/__tests__/connectors.test.ts b/composition-js/src/__tests__/connectors.test.ts index 5988f22c7..06a984e88 100644 --- a/composition-js/src/__tests__/connectors.test.ts +++ b/composition-js/src/__tests__/connectors.test.ts @@ -379,6 +379,7 @@ describe("connect spec and join__directive", () => { path: "" queryParams: "" } + errors: { message: "" extensions: "" } ) type Query { @@ -395,6 +396,7 @@ describe("connect spec and join__directive", () => { queryParams: "" } batch: { maxSize: 5 } + errors: { message: "" extensions: "" } selection: "" ) { id: ID! @@ -440,7 +442,7 @@ describe("connect spec and join__directive", () => { @join__directive(graphs: [WITH_CONNECTORS_V0_1_], name: \\"link\\", args: {url: \\"https://specs.apollo.dev/connect/v0.1\\", import: [\\"@connect\\", \\"@source\\"]}) @join__directive(graphs: [WITH_CONNECTORS_V0_2_], name: \\"link\\", args: {url: \\"https://specs.apollo.dev/connect/v0.2\\", import: [\\"@connect\\", \\"@source\\"]}) @join__directive(graphs: [WITH_CONNECTORS_V0_1_], name: \\"source\\", args: {name: \\"v1\\", http: {baseURL: \\"http://v1\\"}}) - @join__directive(graphs: [WITH_CONNECTORS_V0_2_], name: \\"source\\", args: {name: \\"v1\\", http: {baseURL: \\"http://v1\\", path: \\"\\", queryParams: \\"\\"}}) + @join__directive(graphs: [WITH_CONNECTORS_V0_2_], name: \\"source\\", args: {name: \\"v1\\", http: {baseURL: \\"http://v1\\", path: \\"\\", queryParams: \\"\\"}, errors: {message: \\"\\", extensions: \\"\\"}}) { query: Query } @@ -510,7 +512,7 @@ describe("connect spec and join__directive", () => { type Resource @join__type(graph: WITH_CONNECTORS_V0_2_, key: \\"id\\") - @join__directive(graphs: [WITH_CONNECTORS_V0_2_], name: \\"connect\\", args: {source: \\"v1\\", http: {GET: \\"/resources\\", path: \\"\\", queryParams: \\"\\"}, batch: {maxSize: 5}, selection: \\"\\"}) + @join__directive(graphs: [WITH_CONNECTORS_V0_2_], name: \\"connect\\", args: {source: \\"v1\\", http: {GET: \\"/resources\\", path: \\"\\", queryParams: \\"\\"}, batch: {maxSize: 5}, errors: {message: \\"\\", extensions: \\"\\"}, selection: \\"\\"}) { id: ID! name: String! diff --git a/internals-js/src/specs/connectSpec.ts b/internals-js/src/specs/connectSpec.ts index 73f7bf831..88bdf0396 100644 --- a/internals-js/src/specs/connectSpec.ts +++ b/internals-js/src/specs/connectSpec.ts @@ -27,7 +27,8 @@ const URL_PATH_TEMPLATE = 'URLPathTemplate'; const JSON_SELECTION = 'JSONSelection'; const CONNECT_HTTP = 'ConnectHTTP'; const CONNECT_BATCH = 'ConnectBatch'; -const SOURCE_HTTP = 'SourceHTTP'; +const CONNECTOR_ERRORS = "ConnectorErrors"; +const SOURCE_HTTP = "SourceHTTP"; const HTTP_HEADER_MAPPING = 'HTTPHeaderMapping'; export class ConnectSpecDefinition extends FeatureDefinition { @@ -83,6 +84,7 @@ export class ConnectSpecDefinition extends FeatureDefinition { http: ConnectHTTP selection: JSONSelection! entity: Boolean = false + errors: ConnectorErrors ) repeatable on FIELD_DEFINITION | OBJECT # added in v0.2, validation enforced in rust */ @@ -153,6 +155,11 @@ export class ConnectSpecDefinition extends FeatureDefinition { ConnectBatch.addField(new InputFieldDefinition('maxSize')).type = schema.intType(); connect.addArgument('batch', ConnectBatch); + const ConnectorErrors = schema.addType(new InputObjectType(this.typeNameInSchema(schema, CONNECTOR_ERRORS)!)); + ConnectorErrors.addField(new InputFieldDefinition('message')).type = JSONSelection; + ConnectorErrors.addField(new InputFieldDefinition('extensions')).type = JSONSelection; + connect.addArgument('errors', ConnectorErrors); + connect.addArgument('selection', new NonNullType(JSONSelection)); connect.addArgument('entity', schema.booleanType(), false); @@ -160,6 +167,7 @@ export class ConnectSpecDefinition extends FeatureDefinition { directive @source( name: String! http: ConnectHTTP + errors: ConnectorErrors ) repeatable on SCHEMA */ const source = this.addDirective(schema, SOURCE).addLocations( @@ -190,6 +198,7 @@ export class ConnectSpecDefinition extends FeatureDefinition { SourceHTTP.addField(new InputFieldDefinition('queryParams')).type = JSONSelection; source.addArgument('http', new NonNullType(SourceHTTP)); + source.addArgument('errors', ConnectorErrors); return []; }