Skip to content

Instantly share code, notes, and snippets.

@Emuentes
Forked from brygrill/firebase-graphql-basic.js
Created September 26, 2017 05:24
Show Gist options
  • Save Emuentes/982e1761c04c94473d284fd6b23a0c83 to your computer and use it in GitHub Desktop.
Save Emuentes/982e1761c04c94473d284fd6b23a0c83 to your computer and use it in GitHub Desktop.
Deploying a GraphQL Server with Firebase Functions
// sample graphql server deployed with firebase functions
// minimal server setup
// via http://graphql.org/graphql-js/running-an-express-graphql-server/
const functions = require('firebase-functions');
const express = require('express');
const graphqlHTTP = require('express-graphql');
const { buildSchema } = require('graphql');
// Init express
const app = express();
// Construct a schema, using GraphQL schema language
const schema = buildSchema(`
type Query {
hello: String
}
`);
// The root provides a resolver function for each API endpoint
var root = {
hello: () => {
return 'Hello world!';
},
};
app.use('/', graphqlHTTP({
schema: schema,
rootValue: root,
graphiql: true,
}));
exports.graphql = functions.https.onRequest(app);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment