2.0.3 • Published 5 years ago

formik-apollo v2.0.3

Weekly downloads
18
License
MIT
Repository
github
Last release
5 years ago

formik-apollo

Build Version Size License

A React hook to extract validation errors from a GraphQL request and apply them to a Formik form.

useSubmit

This is a React hook that will automatically extract validation errors from a failed GraphQL response and apply them to a Formik form.

const handleSubmit = useSubmit({
  mutate(data, actions) {
    return client.mutate(MyMutation, { variables: { data } });
  }
});

On the server side, a failed GraphQL response should look like this:

{
  "errors": [
    {
      "message": "Some generic error message",
      "extensions": {
        "code": "VALIDATION_ERROR",
        "problems": {
          "email": ["is required"]
        }
      }
    }
  ]
}

Options

NameRequiredTypeDescription
mutate✔️FunctionPerforms the form submission.
onCompletedFunctionAdd behavior after a successful submission.
onErrorFunctionAdd behavior after a failed submission.
getStatusFunctionExtracts the error message from the GraphQL response.
getErrorsFunctionExtracts field validation errors from the response.
2.0.3

5 years ago

2.0.3-alpha.1

5 years ago

2.0.3-alpha.0

5 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.0.0

6 years ago

0.6.12

6 years ago

0.6.11

6 years ago

0.6.10

6 years ago

0.6.9

6 years ago

0.6.8

6 years ago

0.6.7

6 years ago

0.6.6

6 years ago