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

Validations are unable to return proper error messages with graphql v16 #392

Open
jeanlescure opened this issue Nov 8, 2021 · 0 comments

Comments

@jeanlescure
Copy link

I have started a new project, when I added graphql it installed version ^16.0.1.

In my project I have a mongoose.Schema that validates an email string, the validation itself works, but when the mutation is given an invalid entry rather than returning the validation error message, I'm getting the following error:

{
  "errors": [
    {
      "message": "Support for returning GraphQLObjectType from resolveType was removed in [email protected] please return type name instead.",
      "locations": [
        {
          "line": 7,
          "column": 5
        }
      ],
      "path": [
        "userCreateOne",
        "error"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "message": "Support for returning GraphQLObjectType from resolveType was removed in [email protected] please return type name instead.",
          "stacktrace": [
            "GraphQLError: Support for returning GraphQLObjectType from resolveType was removed in [email protected] please return type name instead.",
            "    at ensureValidRuntimeType (./node_modules/.pnpm/[email protected]/node_modules/graphql/execution/execute.js:816:11)",
            "    at completeAbstractValue (./node_modules/.pnpm/[email protected]/node_modules/graphql/execution/execute.js:784:5)",
            "    at completeValue (./node_modules/.pnpm/[email protected]/node_modules/graphql/execution/execute.js:612:12)",
            "    at executeField (./node_modules/.pnpm/[email protected]/node_modules/graphql/execution/execute.js:477:19)",
            "    at executeFields (./node_modules/.pnpm/[email protected]/node_modules/graphql/execution/execute.js:401:20)",
            "    at completeObjectValue (./node_modules/.pnpm/[email protected]/node_modules/graphql/execution/execute.js:895:10)",
            "    at completeValue (./node_modules/.pnpm/[email protected]/node_modules/graphql/execution/execute.js:624:12)",
            "    at ./node_modules/.pnpm/[email protected]/node_modules/graphql/execution/execute.js:474:9",
            "    at processTicksAndRejections (internal/process/task_queues.js:95:5)",
            "    at execute (./node_modules/.pnpm/[email protected][email protected]/node_modules/apollo-server-core/src/requestPipeline.ts:485:14)"
          ]
        }
      }
    }
  ],
  "data": {
    "userCreateOne": {
      "recordId": null,
      "record": null,
      "error": null
    }
  }
}

If I downgrade graphql to ^15.5.0, then I get a proper validation error message:

{
  "data": {
    "userCreateOne": {
      "recordId": null,
      "record": null,
      "error": {
        "message": "User validation failed: email: Path `email` is invalid (example.com)."
      }
    }
  }
}

I am guessing that the composed resolver returns a GraphQLObjectType as the resolveType when an error occurs, and as the error points out:

Support for returning GraphQLObjectType from resolveType was removed in [email protected] please return type name instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant