Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/janumedia/graphql-firebase-demo
GraphQL + Firebase CRUD example
https://github.com/janumedia/graphql-firebase-demo
crud crud-sample express express-graphql firebase firebase-admin firebase-database graphql nodejs
Last synced: 8 days ago
JSON representation
GraphQL + Firebase CRUD example
- Host: GitHub
- URL: https://github.com/janumedia/graphql-firebase-demo
- Owner: janumedia
- Created: 2018-05-21T14:44:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T11:23:52.000Z (almost 2 years ago)
- Last Synced: 2024-05-30T16:29:05.784Z (6 months ago)
- Topics: crud, crud-sample, express, express-graphql, firebase, firebase-admin, firebase-database, graphql, nodejs
- Language: JavaScript
- Homepage:
- Size: 1020 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple GraphQL + Firebase Demo
This repo provide an example to integrate GraphQL and Firebase
# Depedencies
To simplify this demo is using `express-graphql` as Node HTTP server.
Other depedencies use in this demo is available in `package.json` file.To help development process this repo using `nodemon` to monitor any node change so you will no need to restart the server everytime update the scripts.
# Note
To integrate with Firebase this repo using [firebase-admin](https://www.npmjs.com/package/firebase-admin), make sure to read how to generate [Firebase Admin Private Key](https://firebase.google.com/docs/admin/setup#initialize_the_sdk) as you will need to generate your own `serviceAccountKey.json` and save it on the root project directory
Be sure to manage your [Firebase database rules](https://firebase.google.com/docs/database/security/quickstart) to make it work
# Example query
Open `http://localhost:8080/graphql` on your browser and paste the following queries to test:
Query to addAuthor and return the author's id and name:
```js
mutation {
addAuthor(name: "Stephen Edwin King") {
id
name
}
}```
Query to addBook and return the book's id, title and author's name:
```js
mutation {
addBook(title:"Dreamcatcher", authorid:"888")
{
id
title
author {
name
}
}
}```
Query to get book by ID including author name:
```js
{
book(id:"888"){
title
author{
name
}
}
}```
Query to get all authors and their books
```js
{
authors{
name
books {
title
}
}
}```