Skip to content

Commit

Permalink
Pass locale to link resolver context
Browse files Browse the repository at this point in the history
  • Loading branch information
benmerckx committed Dec 2, 2024
1 parent d42e8e4 commit c103aea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/backend/resolver/EntryResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ export class EntryResolver {
const singleResult = this.isSingleResult(query)
const transact = async (tx: Store): Promise<T> => {
const rows = await dbQuery.all(tx)
const linkResolver = new LinkResolver(this, tx, ctx.status)
const linkResolver = new LinkResolver(this, tx, ctx)
const result = singleResult ? rows[0] ?? null : rows
if (result)
await this.post({linkResolver}, result, query as GraphQuery<Projection>)
Expand Down
8 changes: 5 additions & 3 deletions src/backend/resolver/LinkResolver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Entry} from 'alinea/core/Entry'
import type {InferProjection, Projection} from 'alinea/core/Graph'
import {Status} from 'alinea/core/Graph'
import DataLoader from 'dataloader'
import {Store} from '../Store.js'
import type {EntryResolver} from './EntryResolver.js'
Expand All @@ -12,14 +11,17 @@ export class LinkResolver {
constructor(
public resolver: EntryResolver,
public store: Store,
public status: Status
private ctx: ResolveContext
) {}

load(projection: Projection) {
return new DataLoader<string, object>(
async (ids: ReadonlyArray<string>) => {
const query = this.resolver.query(
new ResolveContext({status: this.status}),
new ResolveContext({
locale: this.ctx.locale,
status: this.ctx.status
}),
{
select: {
entryId: Entry.id,
Expand Down

0 comments on commit c103aea

Please sign in to comment.