graphql-yup-middleware icon indicating copy to clipboard operation
graphql-yup-middleware copied to clipboard

Validations not running or failing with latest version of graphql-js and graphql-relay-js

Open danwetherald opened this issue 3 years ago • 3 comments

Trying to use this but nothing seems to be happening, simple schema that should fail, but nothing gets thrown and the resolver continues to create records that should be failing validation.

export const updateShopMutation = {
  ...updateUser,
  extensions: {
    ...updateUser.extensions,
    yupMiddleware: {
      validationSchema: yup.object().shape({
        input: yup.object().shape({
          name: yup
            .string()
            .required()
            .min(3),
        }),
      }),
    },
  },
};

danwetherald avatar Jan 13 '21 03:01 danwetherald

Are you adding the middleware? You must call applyMiddlewares from graphql-middlewares

JCMais avatar Jan 24 '21 22:01 JCMais

Yes I was, I ended up going with the built in yup() middleware that comes with graphql-shield which seems to be working perfectly.

https://github.com/maticzav/graphql-shield#rules-on-input-types-or-arguments

danwetherald avatar Feb 05 '21 07:02 danwetherald

Having the same issue

rolivegab avatar Mar 15 '21 20:03 rolivegab