This repository has some examples how to use apollo server. Please access Apollo Server to understand more details.
- A simple case. There are no data sources, just exist 1 query.
- A simple case that includes structured data and query, mutation. It works in memory.
- Rest API case. It calls one of GitHub API.
- Another API. It includes 2 APIs, GitHub API and PokéAPI.
- RDB and Authentication. It use PostgreSQL to have user table.
- Clustered server.
- Firestore integration.
These examples use graphql-tools to simplify code.
But I recommend other tools like graphql-code-generator
yarn install
# or
npm install-
Create
.envfile based on.env.example- If you use Postgres example, you need to prepare the information on your Postgres. Of course you can use other RDB like sqlite, mysql etc.
- If you use Firestore example, you need to prepare secret file which approve this app admin.
-
Start server
cd /path/to/example
# cd 0_examples/01_simple
node ./app.jsPlease access http://localhost:4000
This server use firebase-admin to treat firestore data.
This example assume the following data structure on firestore.
{
"test(root collection)": [
{
"auto_generated_id": {
"id": 0,
"name": "string"
}
}
]
}-
Query example
query getTest { tests { id name } }
-
Result
{
"data": {
"tests": [
{
"id": "1",
"name": "name1"
},
{
"id": "2",
"name": "name2"
}
]
}
}