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

Optional results should return null values #150

Closed
d4rken opened this issue Jan 22, 2019 · 2 comments
Closed

Optional results should return null values #150

d4rken opened this issue Jan 22, 2019 · 2 comments
Labels
status: wontfix This will not be worked on

Comments

@d4rken
Copy link
Contributor

d4rken commented Jan 22, 2019

I have a query where the result has optional values

e.g.

    data class SomeData(
        val requiredResult: String,
        val optionalResult: String? = null
    )
type {
    optionalResult: String
    requiredResult: String!
}

Querying this gives me

{
  "data": {
    "someQuery": {
      "requiredResult": "somedata"
    }
  },
  "errors": [],
  "dataPresent": true
}

Clientside, using apollo-client, I didn't get my data. I stumpled upon the same issue here:

apollographql/apollo-client#4267

which suggests that the graphql spec forbids just omitting values and instead we should return:

    "someQuery": {
      "requiredResult": "somedata",
      "optionalResult": null,
    }
@d4rken
Copy link
Contributor Author

d4rken commented Jan 22, 2019

Nvm this works correctly in graphql-kotlin.

@d4rken
Copy link
Contributor Author

d4rken commented Jan 22, 2019

The issue is my json serializer removing the null value.

@d4rken d4rken closed this as completed Jan 22, 2019
smyrick pushed a commit that referenced this issue Jan 22, 2019
* An integration test for optional results.

See #150

* Refactoring into current package structure.

* Cleanup (this will be squashed :o)
@smyrick smyrick added the status: wontfix This will not be worked on label Feb 21, 2019
dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this issue Aug 5, 2022
* An integration test for optional results.

See ExpediaGroup#150

* Refactoring into current package structure.

* Cleanup (this will be squashed :o)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: wontfix This will not be worked on
Development

No branches or pull requests

2 participants