Is there a way to know if a GraphQL field will be resolved using the default resolver?

I want to write a plugin for Apollo server that does some things when the field to be resolved is not using the default resolver.

Is it possible to tell if a field about to be resolved uses the default resolver?

I’ve been digging around in the GraphQLResolveInfo type but can’t figure out if this is possible.

Hello, interesting question! I did some digging of my own and didn’t identify a field that outright provides this information, however I believe the following willResolveField plugin might do the trick, assuming the resolvers variable is your entire resolver map:

async executionDidStart() {
  return {
    willResolveField({source, args, context, info}) {
      const parentType = info.parentType;
      const fieldName = info.fieldName;
      if (!(resolvers[parentType] && resolvers[parentType][fieldName])){
        console.log(`Using default resolver for ${parentType}.${fieldName} `);
      }
    }
  }
}

This code checks your resolver map to see whether there’s an entry for the type-and-field combination that’s about to be resolved. If there isn’t one, I believe it’s reasonable to assume that the default resolver is used. This works fine with aliases.