Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions composition-js/src/__tests__/connectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ describe("connect spec and join__directive", () => {
path: ""
queryParams: ""
}
errors: { message: "" extensions: "" }
)

type Query {
Expand All @@ -395,6 +396,7 @@ describe("connect spec and join__directive", () => {
queryParams: ""
}
batch: { maxSize: 5 }
errors: { message: "" extensions: "" }
selection: ""
) {
id: ID!
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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!
Expand Down
11 changes: 10 additions & 1 deletion internals-js/src/specs/connectSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
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 {
Expand Down Expand Up @@ -83,6 +84,7 @@
http: ConnectHTTP
selection: JSONSelection!
entity: Boolean = false
errors: ConnectorErrors
) repeatable on FIELD_DEFINITION
| OBJECT # added in v0.2, validation enforced in rust
*/
Expand Down Expand Up @@ -153,13 +155,19 @@
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);

Check warning on line 161 in internals-js/src/specs/connectSpec.ts

View check run for this annotation

Codecov / codecov/patch

internals-js/src/specs/connectSpec.ts#L158-L161

Added lines #L158 - L161 were not covered by tests

connect.addArgument('selection', new NonNullType(JSONSelection));
connect.addArgument('entity', schema.booleanType(), false);

/*
directive @source(
name: String!
http: ConnectHTTP
errors: ConnectorErrors
) repeatable on SCHEMA
*/
const source = this.addDirective(schema, SOURCE).addLocations(
Expand Down Expand Up @@ -190,6 +198,7 @@
SourceHTTP.addField(new InputFieldDefinition('queryParams')).type = JSONSelection;

source.addArgument('http', new NonNullType(SourceHTTP));
source.addArgument('errors', ConnectorErrors);

Check warning on line 201 in internals-js/src/specs/connectSpec.ts

View check run for this annotation

Codecov / codecov/patch

internals-js/src/specs/connectSpec.ts#L201

Added line #L201 was not covered by tests

return [];
}
Expand Down