Coder Social home page Coder Social logo

bonde-apis's Introduction

Bonde GraphQL APIs

TODO:

  • Definição resumida
  • Definição tecnica de uma API GraphQL (bibliotecas)
  • Definição de arquitetura e fluxo de acesso

Understand the SETUP

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

How to create a new package?

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

Requirements for adding permissions to resolver

  • 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
  • The session context is passed in every Graphql request (you can see it in the server.js), and it's data are contained inside the Bearer ${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)

How to test if my API is working?

  1. Initiate a localhost tunnel using ngrok
  2. Declare the SCHEMA url in the api-graphql service via enviroment variables
  3. Create a Remote Schema in Hasura using the SCHEMA variable you just declared in the service
  4. Start your API and happy coding!

References boilerplate expressjs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.