This project builds a GraphQL API connected to a Firebase Realtime Database using StepZen. We will use the @rest
directive to generate our GraphQL schema.
You'll need to create a StepZen account first. Once you've got that set up, git clone this repository onto your machine and open the working directory:
git clone https://github.com/stepzen-dev/examples.git
cd examples/with-firebase
Before you can run this example, you need to have a Firebase account and an instance of a Firebase Realtime database. You can find more information on creating a Realtime database in Firebase in the documentation.
Seed the Firebase Realtime database with the JSON data in init.json
, and find your project id in the Firebase console.
You need to add this to the file ./config.yaml
where you need to replace YOUR_FIREBASE_PROJECT_ID
with (in example) my-project-ee56g-default-rtdb
:
# config.yaml
configurationset:
- configuration:
name: firebase_config
project_id: 'YOUR_FIREBASE_PROJECT_ID'
Open your terminal and install the StepZen CLI:
npm install -g stepzen
You need to login here using the command:
stepzen login
After you've installed the CLI and logged in, run:
stepzen start
A proxy of the GraphiQL playground becomes available at http://localhost/5001
(in example http://localhost:5001/api/with-firebase
), which you can use to explore the GraphQL API. Also, the endpoint at which your GraphQL API is deployed gets logged in the terminal. You can query your GraphQL API from any application, browser, or IDE by providing the API Key linked to your account.
You can learn more in the StepZen documentation for REST. Questions? Head over to Discord or GitHub Discussions to ask questions.