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

Check for required fields on create #10857

Closed
wants to merge 3 commits into from
Closed

Check for required fields on create #10857

wants to merge 3 commits into from

Conversation

azrikahar
Copy link
Contributor

Fixes #10610

Before

Here the "description" field is set as required, but we can still create new item via GraphQL or REST without it.

chrome_vrXrOLwS7m

There's no ! appended to String for "description", thus interpreted as nullable:

input create_bar_input {
  id: ID
  name: String
  description: String
}

And we can create it successfully without "description":

chrome_rqk24SjeID

After

  • Added check for required value in fields and set them as non-nullable in GraphQL:

    input create_bar_input {
      id: ID
      name: String
      description: String!
    }

    chrome_rMpaNciuBe

  • Added the same check to REST API:

    chrome_jjhohphHpY


IIRC there was a discussion/issue about required being App only, though I can't recall whether that is intended or not.

Update: on hindsight, this will break for conditional fields that manipulate "required" right? Not sure how can we mitigate that. This might have been the reason why "required" is App only now. @rijkvanzanten Could this change be the wrong direction?

@azrikahar azrikahar marked this pull request as draft January 5, 2022 08:57
@azrikahar
Copy link
Contributor Author

As mentioned in the last part of this PR:

on hindsight, this will break for conditional fields that manipulate "required"

this solution is not accounting for conditions on the App side, so opting to close this PR.

@azrikahar azrikahar closed this Aug 31, 2022
@azrikahar azrikahar deleted the issue/10610 branch August 31, 2022 09:12
@kepi kepi mentioned this pull request Sep 7, 2022
9 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GraphQL Schema is not respecting required fields
2 participants