Skip to content

Commit

Permalink
Type graph resolve result as Promise<T> instead of Query
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaSemenov committed Jun 21, 2024
1 parent e802bea commit f3f5f31
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/selfish-drinks-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"objection-graphql-resolver": minor
"graphql-orm": minor
---

Type graph resolve result as `Promise<T>` instead of `Query`.
4 changes: 2 additions & 2 deletions packages/graphql-orm/src/resolvers/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export class GraphResolver<Orm extends OrmAdapter, Context> {
readonly options: GraphResolverOptions<Orm, Context> = {},
) {}

resolve(
resolve<T>(
query: Orm["Query"],
{ info, ...context }: GraphResolveOptions<Context>,
) {
): Promise<T> {
const tree = this._get_resolve_tree(info)
return this._resolve_type(query, { ...context, tree })
}
Expand Down
4 changes: 2 additions & 2 deletions packages/objection-graphql-resolver/src/resolvers/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class ObjectionGraphResolver<Context> extends GraphResolver<
resolve<Query extends AnyQueryBuilder>(
query: Query,
options: GraphResolveOptions<Context>,
): Query {
return super.resolve(query, options) as Query
): Promise<Query["ResultType"]> {
return super.resolve(query, options)
}

resolvePage<M extends Model, Query extends QueryBuilder<M, M[]>>(
Expand Down

0 comments on commit f3f5f31

Please sign in to comment.