How to add __resolveType resolver for Interfaces?

I’ve got an SDL file with an Interface in it, and a few types that implement the interface. The query returns an array of the interface type.

Interface types requre a __resolveType resolver. Based on @peterp’s answer here I’ve tried adding a resolver both in the SDL file itself, as well as in the service, but in both cases I’m getting a warning stating Type "Tag" is missing a "__resolveType" resolver. What is the correct location and way to add this resolver?


For reference, here are the approaches I’ve tried, but the warning is still thrown:

// graphql/tag.sdl.js

export const resolvers = {
  Tag: {
    __resolveType(tag, context, info) {
      // Type resolver code
// services/tag.js

export const Tag = {
  resolveType: (_args, { root }) => {
    // Type resolver code
1 Like

It looks like maybe the warning happens because the resolvers are not included when makeExecutableSchema is called (here), so __resolveType is not yet defined. But later when addResolveFunctionsToSchema is called it gets merged I think.

I guess this is getting into the weeds, but is there a way to suppress that warning (e.g. by setting requireResolversForResolveType to false)? Or is that just hiding a problem?

Hey, it sounded like your interface types weren’t working, but you got it working now?

I think suppressing the warning would be OK, but obviously not ideal, but at this stage of the schema construction those warnings doesn’t make sense.

I think we should disable the warnings - and figure out if there’s a way to offer you those warnings once the schema is fully formed.

Yes, it’s working since the __resolveType resolver gets merged in during the later step, after the warning has already been thrown. It was probably working all along but the warning made me assume it wasn’t.

However, it only works if I define the __resolveType function in the SDL file, but not if I try using the resolveType function in the services file (my 2nd example above). It’s not a big deal since the first form is working for me, but I was wondering why the 2nd form doesn’t get merged. Maybe that’s a special function name of some sort?

Ok, that’s not ideal, is it possible to share your repo with me so I can figure out what’s going on?

Yes! Just added you to the repository.

Thank you for taking a look!

1 Like

Have this been resolved? I can still see same warning when trying to use union type.

Not quite sure. Could you check in v0.13.0 and loop back with status? If no, please don’t hesitate to ping Peter directly with an @ Thanks! And have a good weekend.

@thedavid @peterp This doesn’t seems resolved, I can still see warnings in console. I tried adding __resolveType and resolveType in graphql type as mentioned above.

Ah, thanks for the update @nexneo

@peterp does any of this ring a bell? April feels like two lifetimes ago in the RedwoodVerse :laughing:

1 Like

this is still a problem. I also cannot work out how to pass the option to apollo

resolverValidationOptions {requireResolversForResolveType: false }

Digging an old thread but this still seems to be an issue. @peterp @thedavid


Hi @TMaYaD Thanks for joining the community and checking in about this!

@Chris could you possibly take the lead on this one? Ultimately, we need to a) confirm this and b) create a GH Issue and c) make sure @peterp and/or @Tobbe (maybe) have it on their radar to get resolved. I’m super focused on the v0.25 release so could use the help managing this. No pressure just let me know. We can loop in someone else if needed.

1 Like

This should be fixed in the next version (27 just came out) ! Thanks @peterp!