Skip to content

Commit

Permalink
fix(graphql): Update AxiosHttp schema to allow for data arrays
Browse files Browse the repository at this point in the history
Closes #1158
  • Loading branch information
SamTolmay committed Apr 6, 2022
1 parent 07286df commit ff4d168
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .yarnrc.yml
Expand Up @@ -74,4 +74,6 @@ packageExtensions:
dependencies:
webpack: "*"

nodeLinker: pnp

yarnPath: .yarn/releases/yarn-sources.cjs
18 changes: 18 additions & 0 deletions packages/graphql/src/connections/AxiosHttp/AxiosHttp.test.js
Expand Up @@ -69,3 +69,21 @@ test('url is not a string', () => {
'AxiosHttp property "url" should be a string.'
);
});

test('data is a string', () => {
const connection = {
method: 'post',
url: 'https://example.com/api',
data: 'value',
};
expect(validate({ schema, data: connection })).toEqual({ valid: true });
});

test('data is an array', () => {
const connection = {
method: 'post',
url: 'https://example.com/api',
data: [{ key: 'value' }],
};
expect(validate({ schema, data: connection })).toEqual({ valid: true });
});
27 changes: 5 additions & 22 deletions packages/graphql/src/connections/AxiosHttp/AxiosHttpSchema.json
Expand Up @@ -12,15 +12,7 @@
},
"method": {
"type": "string",
"enum": [
"get",
"delete",
"head",
"options",
"post",
"put",
"patch"
],
"enum": ["get", "delete", "head", "options", "post", "put", "patch"],
"description": "The request method to be used when making the request",
"errorMessage": {
"type": "AxiosHttp property \"method\" should be a string.",
Expand All @@ -36,7 +28,7 @@
},
"headers": {
"type": "object",
"description": "An object with custom headers to be sent sent with the request. The object keys should be header names, and the values should be the string header values.",
"description": "An object with custom headers to be sent with the request. The object keys should be header names, and the values should be the string header values.",
"errorMessage": {
"type": "AxiosHttp property \"headers\" should be an object."
}
Expand All @@ -49,11 +41,7 @@
}
},
"data": {
"type": ["string", "object"],
"description": "The data to be sent as the request body. Only applicable for request methods 'put', 'post', and 'patch'. Can be an object or a string in the format 'Country=USA&City=New York'.",
"errorMessage": {
"type": "AxiosHttp property \"data\" should be an object or string."
}
"description": "The data to be sent as the request body. Only applicable for request methods 'put', 'post', and 'patch'. Can be an object, array or a string in the format 'Country=USA&City=New York'."
},
"timeout": {
"type": "number",
Expand Down Expand Up @@ -81,19 +69,14 @@
"type": "AxiosHttp property \"auth.password\" should be a string."
}
}

},
"errorMessage": {
"type": "AxiosHttp property \"auth\" should be an object."
}
},
"responseType": {
"type": "string",
"enum": [
"json",
"document",
"text"
],
"enum": ["json", "document", "text"],
"description": "The type of data that the server should respond with.",
"default": "json",
"errorMessage": {
Expand Down Expand Up @@ -132,4 +115,4 @@
}
}
}
}
}

0 comments on commit ff4d168

Please sign in to comment.