Wrong type return in Resolver does not trigger error

Viewed 53

I am building a sever with Graphql. I define a single query which should return a User type. However, in my resolver I am actually returning a string type: "Hello!".

The query executes in the playground without any problem.

My question: the return statement of the resolver expects a User type, instead returns a string. Why is it not failing?

TypeDef

  type User {
    id: String
    email: String
    name: String
  }

  type Query {
    printUser: User
  }

Resolver

const resolvers = {
  Query: {
    printUser: async (parent, args, context, info) => {
      return 'Hello!';
    }
  }

RESOLVER PLAYGROUND

0 Answers
Related