nestjs-typeorm-paginate icon indicating copy to clipboard operation
nestjs-typeorm-paginate copied to clipboard

GraphQL Support

Open danielehrhardt opened this issue 4 years ago • 5 comments

Is there any way to use this with GraphQL? Currently, i am not able to select the correct Query Return Object

danielehrhardt avatar Nov 10 '20 14:11 danielehrhardt

I've honestly not looked at graphQL much. Could you provide an example of how you would create a paginated result with typeORM please? :) I'm guessing the query would look something like this

const query = repository.queryBuilder()
  .select(requiredProperties)
  .where(matching)
  .limit(limitFromQL)
  .from()// last index?

const [count, results] = Partial<MyEntity> query.getManyAndCount();

bashleigh avatar Nov 17 '20 12:11 bashleigh

I think it should be a relay connection not a pagination.

rifatdover avatar Dec 16 '20 00:12 rifatdover

After working with GraphQL for a bit, I think it would be possible to set this up and @rifatdover you're right, it would be a relay connection. I'll see what I can do!

bashleigh avatar May 08 '21 10:05 bashleigh

yes i tried but so basically, ı turn this "https://relay.dev/graphql/connections.htm" later. maybe that gives an idea https://github.com/tamert/nest-typeorm-graphql-jest/blob/0fe1e7bfb22f50e3f45bf4631179f12f620f1282/src/recipes/recipes.resolver.ts#L34

tamert avatar May 27 '21 21:05 tamert

It's works. I have many queries with return

paginate<Entity>(this.repository, optionLimit, queryOptions)

All queries have option IPaginationOption, filters ( custom field ) and sort by any field from Entity

SebaBoler avatar Mar 03 '23 18:03 SebaBoler