There's an optional resolverValidationOptions
object that can be passed to makeExecutableSchema
to enforce some additional resolver validations as shown here:
requireResolversForArgs
will cause makeExecutableSchema
to throw an error if no resolve function is defined for a field that has arguments.
requireResolversForNonScalar
will cause makeExecutableSchema
to throw an error if a non-scalar field has no resolver defined. Setting this to true
can be helpful in catching errors, but defaults to false to avoid confusing behavior for those coming from other GraphQL libraries.
requireResolversForAllFields
asserts that all fields have a valid resolve function.
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.
allowResolversNotInSchema
turns off the functionality which throws errors when resolvers are found which are not present in the schema. Defaults to false
, to help catch common errors.
None of them specifically targets only fields on the root types, but you may be able to make use of one or more.
These options are not exposed directly through ApolloServer, but you can always do:
const schema = makeExecutableSchema({ typeDefs, resolvers, resolverValidationOptions })
const apollo = new ApolloServer({ schema })