prisma1 icon indicating copy to clipboard operation
prisma1 copied to clipboard

Type "Node" is missing a "resolveType" resolver.

Open colevels opened this issue 8 years ago β€’ 23 comments

I am not sure this is a bug. I use Prisma init my project. select typescript-advanced. When I yarn start I always found this console "Type "Node" is missing a "resolveType" resolver. Pass false into ".

I doubt it because I do not yet edit the file but its show this console.

screen shot 2561-04-17 at 15 31 48

colevels avatar Apr 17 '18 08:04 colevels

It's just a warning. To hide it add the resolverValidationOptions in the schema:

const schema = makeExecutableSchema({
  typeDefs: importSchema("./src/schema.graphql"),
  resolvers,
  resolverValidationOptions :{
    requireResolversForResolveType: false
  },
  directiveResolvers
})

gsancho avatar Apr 17 '18 09:04 gsancho

Thanks for bringing this up @vistriter, and your suggested fix @gsancho! πŸ™Œ

I'll keep this issue open for a bit to keep the discussion going, and to see if there are other things that should be adjusted.

marktani avatar Apr 17 '18 09:04 marktani

Thank you! @gsancho. Now, It's not have warned. I will let you know if have a new problem. @marktani

colevels avatar Apr 17 '18 09:04 colevels

Same issue. FYI

Suggested solution doesnt work in this case:

const { GraphQLServer } = require('graphql-yoga');
const { Prisma } = require('prisma-binding');

const resolvers = {
  Query: {
    feed(parent, args, ctx, info) {
      return ctx.db.query.posts({ where: { isPublished: true } }, info);
    },
    drafts(parent, args, ctx, info) {
      return ctx.db.query.posts({ where: { isPublished: false } }, info);
    },
    post(parent, { id }, ctx, info) {
      return ctx.db.query.post({ where: { id: id } }, info);
    }
  },
  Mutation: {
    createDraft(parent, { title, text }, ctx, info) {
      return ctx.db.mutation.createPost({ data: { title, text, isPublished: false } }, info);
    },
    deletePost(parent, { id }, ctx, info) {
      return ctx.db.mutation.deletePost({ where: { id } }, info);
    },
    publish(parent, { id }, ctx, info) {
      return ctx.db.mutation.updatePost(
        {
          where: { id },
          data: { isPublished: true }
        },
        info
      );
    }
  }
};

const server = new GraphQLServer({
  typeDefs: './src/schema.graphql',
  resolvers,
  **resolverValidationOptions: {
    requireResolversForResolveType: false
  },**
  context: req => ({
    ...req,
    db: new Prisma({
      typeDefs: 'src/generated/prisma.graphql',
      endpoint: 'http://localhost:4466/my-app/dev',
      secret: 'mysecret123',
      debug: true
    })
  })
});

idkjs avatar Apr 18 '18 07:04 idkjs

Same issue.

As with @idkjs, the suggested solution doesn't work for me either, I'm afraid. I still get the warning.

Code is shown below:

const { GraphQLServer } = require('graphql-yoga');
const { Prisma } = require('prisma-binding');



const resolvers = {
  Query: {
    info: () => 'This is the API of a Hackernews clone',
    // info: () => null,
    feed: (root, args, context, info) => {
      return context.db.query.links({}, info);
    },

  },


  Mutation: {
    post: (root, args, context, info) => {
      return context.db.mutation.createLink({
        data: {
          url: args.url,
          description: args.description,
        },
      }, info)
    },
  }
}

const server = new GraphQLServer({
  typeDefs: './src/schema.graphql',
  resolvers,
  resolverValidationOptions :{
    requireResolversForResolveType: false
  },
  context: req => ({
    ...req,
    db: new Prisma({
      typeDefs: 'src/generated/prisma.graphql',
      endpoint: 'https://eu1.prisma.sh/some-random-stuff-here/hackernews-node/dev',
      secret: 'mysecret123',
      debug: true,
    }),
  }),
});


server.start(() => console.log('Server is running on http://localhost:4000'));

expatia avatar Apr 18 '18 18:04 expatia

As with @expatia and @idkjs I am getting the same warning.

const server = new GraphQLServer({
  typeDefs: './src/schema.graphql',
  resolvers,
  resolverValidationOptions :{
    requireResolversForResolveType: false
  },
  context: req => ({
    ...req,
    db: new Prisma({
      typeDefs: 'src/generated/prisma.graphql',
      endpoint: 'https://us1.prisma.sh/some-random-stuff/todo-node/dev',
      secret: 'mysecret123',
      debug: true,
    }),
  }),
})
server.start(() => console.log(`Server is running on http://localhost:4000`))

thewillwill avatar Apr 19 '18 15:04 thewillwill

I'm getting this error too when running my tests and this option is abstracted away in a package

wesbos avatar Apr 19 '18 18:04 wesbos

Can you elaborate on how it is abstracted away, @wesbos?

There's a pending PR to add the respective option to graphql-yoga, would that help? https://github.com/graphcool/graphql-yoga/pull/270

marktani avatar Apr 19 '18 18:04 marktani

I'm using graphql-mock in my tets - I guess I will have to PR that option over there as well

wesbos avatar Apr 19 '18 18:04 wesbos

Just upated Prisma from 1.1.3 to 1.6.3 and this warning started to appear when I run yarn run dev

dsoraluz-carecloud avatar Apr 20 '18 23:04 dsoraluz-carecloud

Having the same problem..

idrawdesigns avatar Apr 23 '18 09:04 idrawdesigns

The just released version 1.12.0 of graphql-yoga ships with the functionality of passing the resolverValidationOptions while creating the GraphQLServer instance. Passing requireResolversForResolveType: false will eliminate the warning you've encountered before.

const server = new GraphQLServer({
  typeDefs,
  resolvers,
  resolverValidationOptions: {
    requireResolversForResolveType: false
  }
});

akoenig avatar Apr 26 '18 16:04 akoenig

Cool. Thank you!

expatia avatar Apr 27 '18 12:04 expatia

Thanks for the PR, @akoenig πŸ™Œ

marktani avatar May 01 '18 08:05 marktani

This looks like it's only been implemented in GraphQLServer.... I still get these warnings when using GraphQLServerLambda :(

abelovic avatar May 10 '18 17:05 abelovic

Thanks @abelovic! Please bring this up here: https://github.com/graphcool/graphql-yoga πŸ™‚

marktani avatar May 10 '18 17:05 marktani

const schema = makeExecutableSchema({ typeDefs: importSchema("./src/schema.graphql"), resolvers, resolverValidationOptions :{ requireResolversForResolveType: false }, directiveResolvers }) passing resolverValidationOptions, worked for me. Thanks.

ghost avatar May 28 '18 08:05 ghost

So while the option turns it off, is there a nice explanation somewhere of what the warning was for?

How and why would I implement resolveType so I wouldn't have to turn the option off?

I want to have a good understanding to explain to my students.

Thanks in advance.

jeffbski avatar Jun 07 '18 22:06 jeffbski

@jeffbski: I don't have a full grasp on the details, but my rudimentary understanding is that it stems from the difference between the Prisma server and the application GraphQL server. Specifically, I believe that the error indicates an absence of resolvers in the application server for types in the Prisma server. Of course, those resolvers are often not necessary as not every Prisma type needs to be functional on the application side.

In trying to dig up some info., I read the bottom of this ReadMe:

requireResolversForResolveType will require a resolveType() method for Interface and Union types. This can be passed in with the field resolvers as __resolveType(). False to disable the warning.

and, more descriptively, this post!

All the other GraphQL interfaces from the GraphQL server schema (which is the entire schema and not only a part of it as before) are not resolved. But you don’t need to resolve them, because they are not used in your actual GraphQL queries and mutations in your application. Thus, you can deactivate these warnings.

jangerhofer avatar Jun 24 '18 02:06 jangerhofer

@jangerhofer

Your comment is accurate, with this small adjustment:

Specifically, I believe that the error indicates an absence of resolvers in the application server for types in the Prisma server.

The warning is specifically about the Node interface (not type).


You can also implement Node resolver to make this warning go away, instead of disabling the warning.

marktani avatar Jun 25 '18 11:06 marktani