Skip to content

apollo-datasource-rest: Dont' parse as json when status code is 204 No Content#2446

Merged
abernix merged 6 commits into
apollographql:release-2.5.0from
bartverbruggen:master
Apr 5, 2019
Merged

apollo-datasource-rest: Dont' parse as json when status code is 204 No Content#2446
abernix merged 6 commits into
apollographql:release-2.5.0from
bartverbruggen:master

Conversation

@bartverbruggen

Copy link
Copy Markdown
Contributor

No description provided.

@apollo-cla

Copy link
Copy Markdown

@bartverbruggen: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@bartverbruggen

Copy link
Copy Markdown
Contributor Author

Any idea what could go wrong on the tests? It fails on tests I didn't even made changes on.. I've cleared cache etc...

@abernix

abernix commented Apr 4, 2019

Copy link
Copy Markdown
Member

Seems to be failing for potentially important reasons related to the change?

image

@bartverbruggen

Copy link
Copy Markdown
Contributor Author

@abernix How is that error related to my changes? Even after reverting all my edits, i still get those errors. Loosing it on this one..

I'll close this PR and create an issue, hoping that someone else can fix this small but vital issue.

@abernix

abernix commented Apr 4, 2019

Copy link
Copy Markdown
Member

I'm running the tests locally and I'm seeing the failures as well, however when I revert the two commits in this PR (i.e. git revert HEAD HEAD~), the tests pass again.

contentType &&
(contentType.startsWith('application/json') ||
contentType.startsWith('application/hal+json'))
response.status !== 204 ||

@abernix abernix Apr 4, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you didn't mean to put this as an && inside the parenthesis that contain contentType.startsWith(...) || ...?

The failing tests are because of Content-type: text/plain and you're always short-circuiting when the response.status !== 204, which would be most all of the time, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is embarrassing..., it, indeed, should have been && instead of ||, it is not necessary to put it inside the parenthesis because it should pass all three conditions.

Thank you very much!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to be embarrassed. That's what failing tests and code-reviews are meant to help with. 😄

Thank you for the first-time contribution!

@abernix abernix added this to the Release 2.5.0 milestone Apr 5, 2019
@abernix abernix changed the base branch from master to release-2.5.0 April 5, 2019 14:00
abernix added a commit to ryandrewjohnson/apollo-server that referenced this pull request Apr 5, 2019
@abernix abernix merged commit aa7c2b8 into apollographql:release-2.5.0 Apr 5, 2019
abernix pushed a commit that referenced this pull request Apr 5, 2019
* add no-cache headers to PersistedQuery error responses

* fix defaultHeaders typo

* remove try/catch on hasPersistedQueryError replace with Array.isArray check

* Add CHANGELOG.md for #2446.
@abernix

abernix commented Apr 5, 2019

Copy link
Copy Markdown
Member

Thanks for this PR!

It's been published in apollo-datasource-rest@0.4.0-alpha.2 and is paired with an upcoming Apollo Server 2.5.0 release: apollo-server@2.5.0-alpha.3. Please try it out and report back if you've had any problems, or if it works properly!

@StevenVerbiest

Copy link
Copy Markdown

Fix seems to work. Great job!

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants