AbdulxaqDev / rsschool-nodejs-task-graphql

GraohQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assignment: Graphql

Tasks:

  1. Add logic to the graphql endpoint: ./src/routes/graphql.
    Constraints and logic for gql queries should be done based on restful implementation.
    1.1. npm run test-queries
    1.2. npm run test-mutations
  2. Limit the complexity of the graphql queries by their depth with graphql-depth-limit package.
    Use value "5" for package.
    2.1. npm run test-rule
  3. Solve n+1 graphql problem with dataloader.
    You can use only one "findMany" call per loader to consider this task completed.
    3.1. npm run test-loader
    3.2. npm run test-loader-prime
    When you query all users, you don't have to use the database again when you want to find subs.
    Pre-place users in the appropriate dataloader cache.
    To determine if a user is a sub you need to do the appropriate join (include).
    But only do a join when you need it. You can use graphql-parse-resolve-info package to parse GraphQLResolveInfo to determine if subs are expected in the response.

Info:

It is forbidden to add new npm dependencies.
You should only modify/add the code inside the folder ./src/routes/graphql.
Do not create files with the name "index.ts". This name is reserved for fastify plugins.
You are responsible for using style configs that are in the repository.
Make sure the important files have not been changed: npm run test-integrity.
If the test was partially completed, then it is considered not completed.
If the one test was not completed, then the subsequent ones are considered not completed.
You are free to use schema-first or stick to the default code-first.

Steps to get started:

  1. Install dependencies: npm ci
  2. Create .env file (based on .env.example): ./.env
  3. Create db file: ./prisma/database.db
  4. Apply pending migrations: npx prisma migrate deploy
  5. Seed db: npx prisma db seed
  6. Start server: npm run start

Useful things:

  • Database GUI: npx prisma studio
  • Tests modify the db, so if it seems to you that the db has become too large, you can clear it: npx prisma migrate reset (also triggers seeding)
  • Swagger: /docs

About

GraohQL


Languages

Language:TypeScript 97.8%Language:JavaScript 2.2%