TODO:
- Definição resumida
- Definição tecnica de uma API GraphQL (bibliotecas)
- Definição de arquitetura e fluxo de acesso
Install
# Install the package manager
yarn global add pnpm
# Install packages dependencies
pnpm i
Libraries
- Build (Node, Typescript)
- Server (Express, GraphQL)
- Log (Pino)
- Tests (Jest)
Commands
- Tests:
pnpm m run tests # pnpm m run coverage
- Development server:
pnpm m run dev
- Production build and start:
pnpm m run build
pnpm m run start
Install cookiecutter, following setup on Debian/Ubuntu OS:
sudo apt-get install cookiecutter
PS: In Ubuntu version 20.04 there's no package available for cookiecutter
(yet). You'll need to install it via Python packages.
Copy a base project to GraphQL API:
cookiecutter example-api/ -o packages/
Run tests on your new GraphQL API, change example
by the domain
configuration made in the previous step:
pnpm m run tests --filter example-api
- The permissions for the user that made the request are checked before our resolver is called
community_id
must be passed from the resolver args input- That's where the permissions-util get the
community_id
- That's where the permissions-util get the
- The session context is passed in every Graphql request (you can see it in the
server.js
), and it's data are contained inside theBearer ${token}
- More info about context and authentication in this Apollo docs article
- If you wish to import a resolver inside another, you must pass the context via parameters (see an example of this in the
create_match
resolver inside the redes package)
- Initiate a localhost tunnel using
ngrok
- Declare the SCHEMA url in the
api-graphql
service via enviroment variables - Create a Remote Schema in Hasura using the SCHEMA variable you just declared in the service
- Start your API and happy coding!
- https://github.com/metachris/typescript-boilerplate
- https://github.com/IBM/nodejs-express-app/tree/master/server/routes
- https://github.com/jsynowiec/node-typescript-boilerplate
- https://github.com/hagopj13/node-express-boilerplate
- https://github.com/danielfsousa/express-rest-boilerplate
- https://github.com/gothinkster/node-express-realworld-example-app