-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Google cloud functions? #357
Comments
The AWS Lambda integration is designed to export a function for API Gateway proxy integration not Google Cloud. You would be better off using the graphql-server-core package and converting the request object into one that can be read by that package. Is google cloud functions still in beta? It might be too early to write an integration for it. |
Thanks for the info. Yes it is still in beta |
I'd also be happy to accept a PR that adds a separate package for google cloud functions, just like we have one for lambda. 😉 |
Is there anywhere I should look to better understand the internals? Or just look over the current code to make my own :) |
Yeah, I would just look at what the lambda or micro package does and then roll your own! It's pretty straightforward. |
@zackify the http logic itself is pretty abstract in |
I have also been looking into hosting GraphQL on GCP Cloud Functions / Cloud Functions for Firebase. I've come across a number of resources that have confused me with the use of ExpressJS in the context of Cloud Functions: Here I see people passing an ExpressJS server into the Firebase Cloud Functions But then I came across a single person here who has concerns about creating an express app in a Cloud Function. This makes me question whether I should simply use graphql-server-express instead of working on a custom integration. So I'm not sure which method here is correct in the context of ExpressJS in Cloud Functions for Firebase. I've posted on SO with the following questions:
TLDR; if you can use ExpressJS server as described here in Google/Firebase Cloud Functions could we then not just rely on using graphql-server-express in the same manner? |
It does seem like the google cloud function takes in an express Request/Response object. It also seems like the firebase google cloud function has several triggers. The http trigger is created using this function Does seem like the implementation of Not sure how to answer the other questions about function lifetime still learning about GCP. |
I can confirm that the Sample code: // graphql-server-express
var functions = require("firebase-functions");
const bodyParser = require("body-parser");
const express = require("express");
const graphqlExpress = require("graphql-server-express").graphqlExpress;
const mySchema = ...;
var graphQLServer = express();
graphQLServer.use("*", bodyParser.json(), graphqlExpress({ schema: mySchema }));
// CF for Firebase with graphql-server-express
exports.graphql = functions.https.onRequest(graphQLServer); called using however to use GraphiQL as well you must do the following: // import graphiql
const graphiqlExpress = require("graphql-server-express").graphiqlExpress;
// assign specific URLs - in place of the "*" catchall
graphQLServer.use("/graphql", bodyParser.json(), graphqlExpress({ schema: mySchema }));
graphQLServer.use("/graphiql", graphiqlExpress({ endpointURL: "/graphql" })); and then call the method with I still do not have an answer for how definitions of objects outside the function definition are handled or how Cloud Functions can take an entire ExpressJS object and just magically work seemingly stripping the object back to it's Assuming there are no drawbacks to initializing the express object outside of the function export, I personally don't see a reason in increasing the code surface area by creating a |
Also, how would you do this with subscriptions? Is that not possible I'm guessing? |
This |
@jthegedus just to close the loop, would you mind sending a PR to the README and docs here adding the code snippet about google cloud functions? |
@stubailo It would be my pleasure 😄 |
@stubailo @jthegedus did an official best practice example ever make the docs? I presume not as I can't seem to find it in in the server docs Are their any plans to add one? I have used the the the example walk through in this article and it worked well. Could I suggest reviewing it and maybe adding it to the docs ? let me know if there is any way I could help with that. 😄 |
@Paddy-Hamilton I did record this early Jan in my backlog of things to do. I've scheduled time this weekend to address this. I'll ping you in the PR if you wish to give feedback. (that example you linked does actually reference my article for doing this on Firebase, I just never got around to vanilla Google Cloud Functions) |
@jthegedus ha, so it does, thanks for the help 👍 Sounds good, will take a look at the PR, although i'm a relative graphql and GCF newbie so my feedback maybe limited. I'll help in whatever way I can. |
Can I use the lambda package and run it on google cloud? I'm looking into using google cloud functions with the project. Sorry I didn't investigate first. Just wanted to see if anyone else is interested as well!
The text was updated successfully, but these errors were encountered: