Skip to content

Commit

Permalink
feat: addResolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Sep 27, 2024
1 parent c6f0d67 commit 0bd24db
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/core/src/resolvers/resolverStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { MoquerieInstance } from '../instance.js'
import { MockFileHandler } from '../mock/mockFileHandler.js'
import type { Resolver } from '../types/resolver.js'
import type { Resolver, ResolverBaseDefinitions } from '../types/resolver.js'

/**
* @deprecated use `ResolverStore` instead
Expand Down Expand Up @@ -55,3 +56,18 @@ export class ResolverStore extends MockFileHandler<Resolver> {
}
}
}

export async function addResolvers(mq: MoquerieInstance, resolvers: ResolverBaseDefinitions) {
const ctx = await mq.getResolvedContext()
for (const resourceName in resolvers) {
for (const fieldName in resolvers[resourceName]) {
const action = resolvers[resourceName][fieldName]
ctx.resolvers.items.push({
resourceName,
fieldName,
action,
file: '__added-resolver',
})
}
}
}

0 comments on commit 0bd24db

Please sign in to comment.