So I have this job op with GraphQL requirements, thus I decided to prepare myself for the position.
First I read the GraphQL doc here, then I started to redocument it since TBH I find it more engaging when I write doc for a tech than simply reading it (the result can be found here).
Then after that I decided to get a bit exercise in NestJS, thus I read their doc as well (RTFM) here. So now I reached a point where I realized I do not wanna spend my precious time writing CRUD-like ops.
So I tried out a couple of packages such as:
-
prisma-nestjs-graphql
: You can find my conclusion about it here. But if you wanna know the final answer, it is a big NO for me. -
nestjs-query
: I tried this one and switched from Prisma to TypeORM. Like always I am documenting what I am doing here. But the bottom line is that this lib won the prize.
So now that I've cleared the air first I can explain from where I started my journey:
Like I said I decided to develop a dummy NestJS app with GraphQL to have a feeling for what's it like to build a GraphQL API. Talking more accurate, I was really interested in knowing "pagination and filtering".
-
I went TDD, meaning I wrote my e2e tests first. Thus I faced a big picture kind of question: "how my API should look like?"
- How others approach this question?
- Do we have a standard way of doing things?
Then A more fundamental question hit me, how should I go about caching? So I asked google about it and in the results I found a very insightful video about caching in GraphQL.
-
By this time I was feeling more confused than before. So I just decided to narrow the question down to what is the most common practice to have pagination in GraphQL and soon I found my answer. It is called "Connections" and I thought that those guys at Facebook ought to need caching. So it is pretty safe to use it.
BTW in case you like to know about pagination intricacies and its variants you can read my doc over here.
And if you are interested in "Connections" design pattern read this doc.
Now I am writing E2E tests for this dummy NestJS app called
botprobe-nest
here. Have not pushed anything yet though at the time of writing this article.
My next stop would be contributing more in nestjs-query
project since it lacks some stuff that I think I need for sure.
BTW I just did upgrade a 3rd-party lib to its latest major version, thus we also release version 8.0.0.
Next step
After I finish writing E2E tests I am gonna try out caching. So stay tuned for the next part. Also lemme know in the comments if I can improve something.
Top comments (0)