Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To use this plugin is it necessary to get all records from the database with one request? #381

Closed
dcristafovici opened this issue Apr 21, 2022 · 0 comments

Comments

@dcristafovici
Copy link

Hello, I have one question. I started to use this packet, for the beginning I had created a special function Connection that permits me to get in response to the new structure of the object.
After I have created new class that I use it for type of GraphqQL response

@ObjectType()
export class CategoryConnection extends Connection<Category>(Category) {}

Now my resolver looks that

@Query(() => CategoryConnection)
  async findCategories(
    @Args('data') data: GraphqlRelayParams,
  ): Promise<CategoryConnection> {
    return connectionFromPromisedArray(this.categoryService.find(), data);
  }

All is okay, because I have been getting the expected result and parameters are working excellently.
image

Anyway I am wondering if it is the right approach. As you can see in resolver I call method find from categoryService, that returns all records from database

 find(): Promise<Category[]> {
    return this.categoryRepository.createQueryBuilder('category').getMany();
  }

In the end, as I understand, when User makes a request, service find returns all records ( getMany) and graphql return to user only neediest elements( by after and limit params). I guess that service also should get params, and take from the database only necessary records. Or am I wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant