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

Return null data when data is empty #140

Merged
merged 1 commit into from
Jun 3, 2021
Merged

Return null data when data is empty #140

merged 1 commit into from
Jun 3, 2021

Conversation

OlfaKaroui
Copy link
Contributor

@OlfaKaroui OlfaKaroui commented May 31, 2021

We encountered an issue where the returned response data is replaced by an empty object when it's null. This happens when response code is 200 and an error is returned. Some libraries don't accept this and according to the gql specs data should be either null or populated {}.

Example :
Backend returns this response to a query:

{
  "data": null,
  "errors": [
    {
      "extensions": {
        "category": "client"
      },
      "message": "error message",
    }
  ]
}

You can see that in this case, data is null. Gateway then replaces that null with {} and returns this response :

{
  "data": {},
  "errors": [
    {
      "extensions": {
        "category": "client"
      },
      "message": "error message",
    }
  ]
}

This pull request is meant to address that issue. Let me know what you think!

@OlfaKaroui OlfaKaroui marked this pull request as ready for review May 31, 2021 11:30
@OlfaKaroui OlfaKaroui changed the title return null when data struct is empty Return null data when data is empty May 31, 2021
@AlecAivazis
Copy link
Member

Thanks for submitting this and I appreciate the extra tests 😄

I'll kick off the tests now and merge it in once we get a 👍

@OlfaKaroui
Copy link
Contributor Author

OlfaKaroui commented Jun 3, 2021

@AlecAivazis Thank you! Any updates about the status of the PR ? 😄

@AlecAivazis AlecAivazis merged commit 5eee34e into nautilus:master Jun 3, 2021
@AlecAivazis
Copy link
Member

AlecAivazis commented Jun 3, 2021

Thanks for the reminder!

edit: this is now published under v0.1.17

@obukhov obukhov deleted the return-null-data branch June 4, 2021 07:20
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

Successfully merging this pull request may close these issues.

None yet

2 participants