Skip to content
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

[Feature Request] Add query params when create/update resource #175

Open
yosuadc3 opened this issue Jun 4, 2020 · 2 comments
Open

[Feature Request] Add query params when create/update resource #175

yosuadc3 opened this issue Jun 4, 2020 · 2 comments

Comments

@yosuadc3
Copy link

yosuadc3 commented Jun 4, 2020

Hello @CodingItWrong , currently restate-client supports create/update resource only data.

create(partialRecord) {
const record = Object.assign({}, partialRecord, { type: this.name });
const requestData = { data: record };
return this.api
.post(`${this.name}`, requestData)
.then(extractData)
.catch(extractErrorResponse);
}
update(record) {
// http://jsonapi.org/faq/#wheres-put
const requestData = { data: record };
return this.api
.patch(`${this.name}/${record.id}`, requestData)
.then(extractData)
.catch(extractErrorResponse);

But my API able to supports post/patch request data with query params e.g:
[POST] https://api.my-app.com/v1/users?include=roles. This feature request can increase efficiency when create/update resource with included resource on result only with single http request, instead of double http request (post then get request with included).

Can you support this feature request?

@CodingItWrong
Copy link
Contributor

@yosuadc3 This client attempts to follow the JSON:API specification. Do you know if there is official or widespread use of this technique in JSON:API-compliant APIs? Is this functionality coming from an open-source JSON:API server library, or is it custom-coded?

I'm looking through the JSON:API specification https://jsonapi.org/format/ and I can't find a mention about using an include query string parameter in a POST request. The "Inclusion of Related Resources" section, which is where the include query string parameter, is listed under the "Fetching Data" section with only GET request examples. The include query string parameter isn't mentioned in the "Creating, Updating and Deleting" section. Using a query string with POST requests is valid HTTP, but it's rare to do.

I understand the value this would add to reduce requests, but as this library sticks with the JSON:API specification I want to follow its specified functionality rather than adding extensions.

@CodingItWrong
Copy link
Contributor

FYI, this library will be unmaintained going forward.

If you need new features or fixes, I recommend forking the repo and making changes, or finding an alternate library that meets your needs.

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

No branches or pull requests

2 participants