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

Cannot return null for non-nullable field Message.id. #243

Open
brunolm opened this issue Nov 22, 2019 · 1 comment
Open

Cannot return null for non-nullable field Message.id. #243

brunolm opened this issue Nov 22, 2019 · 1 comment
Labels
kind/question Developer asked a question. No code changes required.

Comments

@brunolm
Copy link

brunolm commented Nov 22, 2019

I'm calling setMessage trying to return id from the created message. But if there's an error I get the following message:

Cannot return null for non-nullable field Message.id.

The only way to avoid this is to change from ID! to ID. Is there anything I can do to get the actual error instead of this?

Request:

POST http://localhost:4000/graphql
Content-Type: application/json
X-REQUEST-TYPE: GraphQL

mutation setMessage {
  setMessage(input: { message: "a@@gmail.com"}) {
    error
    message
    id
  }
}

resolver

import * as yup from 'yup'

export const messageMutations = {
  setMessage: {
    validationSchema: yup.object().shape({
      input: yup.object().shape({ message: yup.string().email() }),
    }),

    resolve(_, { input }) {
      return { id: (Math.random() * 100) | 0, message: input.message }
    },
  },
}
@maticzav maticzav added the kind/question Developer asked a question. No code changes required. label May 23, 2021
@maticzav
Copy link
Owner

@brunolm I am not sure I understand how graphql-middleware fits in here. Is it possible that the yup validation function returns something other than an error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Developer asked a question. No code changes required.
Projects
None yet
Development

No branches or pull requests

2 participants