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 iLibraries
- 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 startInstall 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_idmust 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_matchresolver inside the redes package)
- Initiate a localhost tunnel using
ngrok - Declare the SCHEMA url in the
api-graphqlservice 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