Skip to content

feat(useOnResolve): new skipDefaultResolvers options #2133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/plugins/on-resolve/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export type UseOnResolveOptions = {
* @default true
*/
skipIntrospection?: boolean;
/**
* Skip wrapping fields that have the default resolver (no custom resolver).
*
* @default false
*/
skipDefaultResolvers?: boolean;
};

/**
Expand All @@ -59,6 +65,7 @@ export function useOnResolve<PluginContext extends Record<string, any> = {}>(
for (const type of Object.values(schema.getTypeMap())) {
if ((!opts.skipIntrospection || !isIntrospectionType(type)) && isObjectType(type)) {
for (const field of Object.values(type.getFields())) {
if (opts.skipDefaultResolvers && (!field.resolve || field.resolve === defaultFieldResolver)) continue;
if (field[hasWrappedResolveSymbol]) continue;

let resolver = (field.resolve || defaultFieldResolver) as Resolver<PluginContext>;
Expand Down