Skip to content

Commit

Permalink
feat(useOnResolve): new skipDefaultResolvers options
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum authored Jan 5, 2024
1 parent b26352b commit 6825b48
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit 6825b48

Please sign in to comment.