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

Contact API fields return null instead of error if they are blank #2493

Merged
merged 2 commits into from
May 31, 2024

Conversation

kimadactyl
Copy link
Member

@kimadactyl kimadactyl commented May 28, 2024

For input:

curl -v -H "Content-Type: application/json" -d '{"query": "query { partner(id: 289) { id summary url contact { name email telephone } } }" }' https://placecal.org/api/v1/graphql

Before

{
  "data": {
    "partner": {
      "id": "289",
      "summary": "Material Grrrlz is a community of fiber artists dedicated to celebrating the work of young women \u0026 queer people💗",
      "url": "https://www.materialgrrrlz.com/about-us",
      "contact": null
    }
  },
  "errors": [
    {
      "message": "Cannot return null for non-nullable field Contact.email"
    }
  ]
}

After

{
  "data": {
    "partner": {
      "id": "289",
      "summary": "Material Grrrlz is a community of fiber artists dedicated to celebrating the work of young women \u0026 queer people💗",
      "url": "https://www.materialgrrrlz.com/about-us",
      "contact": {
        "name": "Material Grrrlz",
        "email": null,
        "telephone": null
      }
    }
  }
}

Fixes #2474

@kimadactyl kimadactyl requested a review from katjam May 28, 2024 16:23
Copy link
Member

@katjam katjam left a comment

Choose a reason for hiding this comment

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

Great catch. I am assuming null: false means it's not nullable - but we do want it to be.

@kimadactyl
Copy link
Member Author

Great catch. I am assuming null: false means it's not nullable - but we do want it to be.

Exactly - one null was erroring out the whole object. Note this means the other end needs to accept Maybe String if it doesn't already?

@kimadactyl kimadactyl enabled auto-merge (squash) May 31, 2024 12:40
@kimadactyl kimadactyl merged commit fa27573 into main May 31, 2024
2 checks passed
@kimadactyl kimadactyl deleted the fix-graphql-contact-error branch May 31, 2024 12:44
@kimadactyl kimadactyl changed the title Contact fields return null instead of error if they are blank Contact API fields return null instead of error if they are blank Jun 6, 2024
@honor-gfsc
Copy link

Someone else with more knowledge needs to verify this

@kimadactyl
Copy link
Member Author

validated

curl -v -H "Content-Type: application/json" -d '{"query": "query { partner(id: 10) { id summary url contact { name email telephone } } }" }' https://placecal-staging.org/api/v1/graphql

->

{"data":{"partner":{"id":"10","summary":"Work for Change provides co-operatively managed workspace including offices, artists studios, workshops, cafe and theatre space. ","url":"","contact":{"name":"","email":"[email protected]","telephone":"0161 226 7696"}}}}

@katjam
Copy link
Member

katjam commented Jun 29, 2024

In the given example, name is an empty string. I think this issue was with allowing values to be null. Still uncertain why only that one partner saves the values as null when the rest are empty string.

validated

curl -v -H "Content-Type: application/json" -d '{"query": "query { partner(id: 10) { id summary url contact { name email telephone } } }" }' https://placecal-staging.org/api/v1/graphql

->

{"data":{"partner":{"id":"10","summary":"Work for Change provides co-operatively managed workspace including offices, artists studios, workshops, cafe and theatre space. ","url":"","contact":{"name":"","email":"[email protected]","telephone":"0161 226 7696"}}}}

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.

[Bug]: Contact information data is not always feeding through to graphql
3 participants