Skip to content

Returning Relay-connection style responses from custom resolvers #247

Open
@rinormaloku

Description

@rinormaloku

How to convert the result of the database into a relay-connection style response? This is a workaround that I am currently using:

@Query(() => ActivitiesViewConnection)
  async activitiesViews(
    @Args() query: ActivitiesViewQuery,
  ): Promise<ConnectionType<ActivitiesView>> {
    
    // custom and complex querying logic
    let qb = this.filterQueryBuilder.select(query);
    const [result, total] = await qb.getManyAndCount();

    return ActivitiesViewConnection.createFromPromise(
      (q) => Promise.resolve(result),
      query,
      (q) => Promise.resolve(total),
    );
  }

I would prefer a cleaner way of mapping the result into a relay-connection style response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions