This repo shows how to implement an architecture using Express + GraphQL + Sequelize in the backed, and an Ionic application in the frontend.
The logic is a simple CRUD of contacts with fields: name, address and phone.
The data layer is managed by Sequelize using SQLite as persistence.
GraphQL is handled with the Apollo libraries.
Host your GraphQL Server on Cloud Functions enabling rapid development with GraphQL on a low-cost, auto-scaling web server leveraging Firebase's sweet, sweet developer experience.
Cloud Functions can accept an Express Server object directly, so leverage the Apollo apollo-server-express pacakge to setup our GraphQL server.
Schema: https://us-central1-<project-name>.cloudfunctions.net/api/schema
GraphiQL: https://us-central1-<project-name>.cloudfunctions.net/api/graphiql
GraphQL: https://us-central1-<project-name>.cloudfunctions.net/api/graphql?<query>
You need to have installed on your computer:
- Node.js
- Yarn (optional) # npm install -g yarn
- Firebase tools # npm install -g firebase-tools
git clone https://github.com/jonathanferreyra/ionic-graphql-firebase-starter
cd ionic-graphql-firebase-starter
yarn install
# install firebase functions packages
cd functions/ && yarn install
# install ionic packages
cd app/ && yarn install
Note: you can use npm install
instead of yarn install
- Node 6.11.1
npm install -g sequelize-cli
sequelize model:create --name Contact --attributes name:string,address:string,phone:string
sequelize db:migrate
sequelize db:seed:all
yarn serve
This will serve the Cloud Functions locally using the Firebase emulator.
After running the first time, you can rerun using yarn test
or what is the same cd dist/functions && node server.js
From the app you can try operations: create, edit, update, list & search
yarn deploy
N.B.: Replace <project-name>
in the .firebaserc
to connect the project to your Firebase project.