Skip to content

Instantly share code, notes, and snippets.

@mizchi
Last active November 27, 2018 22:05
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizchi/cc1ffd86d79787dc4cda30fe016c3513 to your computer and use it in GitHub Desktop.
Save mizchi/cc1ffd86d79787dc4cda30fe016c3513 to your computer and use it in GitHub Desktop.
GraphQL on Firebase
/* @flow */
import * as functions from 'firebase-functions'
import express from 'express'
import Cors from 'cors'
import { graphqlExpress } from 'apollo-server-express'
import bodyParser from 'body-parser'
import { makeExecutableSchema } from 'graphql-tools'
const schema = makeExecutableSchema({typeDefs: [/* Your schema.graphql */], resolvers: {/* Your resolver */} })
const cors = Cors({ origin: true })
const server = express().use(
cors,
bodyParser.json(),
graphqlExpress({ schema, context: {} })
)
export const graphql = functions.https.onRequest(server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment