Skip to content

Don't error if optional field not present #561

@deoqc

Description

@deoqc

Sometimes I have a form with not all fields required, and it will be used as inputs to a mutation.

const query = gql`
  mutation myForm(
    $name: String!
    $tags: [String!]
  ) {
    createSomethingAwesome(
      name: $name
      tags: $tags
    ) {
       id
       someField
    }
`

But I actually need to pass an empty tags to variables. If I pass only variables: { name } it will error.

Should apollo-client take care of this?

Right now I'm doing variables: { tags: [], ...formFields } instead of variables: formFields since formFields won't have tags key if it is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions