-
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
Implementation of Apollo Server 2 for Google Cloud Functions #1446
Implementation of Apollo Server 2 for Google Cloud Functions #1446
Conversation
@reaktivo: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
dff1d09
to
4861872
Compare
fcd29db
to
30174e2
Compare
30174e2
to
2424dfa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome @reaktivo - everything here looks great! The only small suggestion I have is to maybe rename the gqlApollo.ts
and gqlApollo.test.ts
files to be more inline with the naming used by the other integrations. The Lambda integration uses lambdaApollo.ts
for example, CloudFlare uses cloudflareApollo.ts
, etc. Maybe something like gcfApollo.ts
or googleCloudApollo.ts
? Honestly, this is a super minor thing, and I don't really consider it essential to getting this approved. Thanks vey much for working on this!
Hah! That was a funny slip up, I meant them to be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reaktivo Thank you so much for the PR! Super excited about GCF support.
I left a couple of comments on the documentation that would help people start using the package. Can't wait to get this out the door 🎉
|
||
## Getting request info | ||
|
||
To read information about the current request from the API Gateway event (HTTP headers, HTTP method, body, path, ...) or the current Google Cloud Function (Function Name, Function Version, awsRequestId, time remaining, ...) use the options function. This way they can be passed to your schema resolvers using the context option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awsRequestId
seems out of place. I'm not super familiar with GCF, so it totally could be a thing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed mentions to aws and simplified this section
#### 2. Configure your Cloud function and deploy | ||
|
||
Set the _Function to execute_ option to _handler_ | ||
and deploy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick section here on how to deploy the GCF would be incredible! Hopefully it includes a link to some of GCF's documentation as well
In the lambda world, we have to do some special things to ensure that all requests are piped to the handler, so that the OPTIONS request to cors is properly routed. My naive assumption is that GCF has similar configuration requirements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a bit more details. But in general GCF doesn't requiring much additional configuration
|
||
#### 1. Write the API handlers | ||
|
||
In a file named `graphql.js`, place the following code: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a lambda environment, the specific file was necessary, since the configuration referenced graphql.handler
. Does GCF have the same sort of dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed it's actually necessary for the js file to be named index.js since the configuration only allows setting the directory of the function and not the file itself.
The changes are on their way, thanks for the feedback! |
bd9b26b
to
22d186c
Compare
4cf1fd5
to
784cd5f
Compare
784cd5f
to
25fa7bd
Compare
Thanks for these changes @reaktivo. We should be all set here, so LGTM! |
The `apollo-server-cloud-functions` has been been mis-referenced (or referenced inconsistently) since its original inception in #1446 when its package directory was `apollo-server-cloud-function` (singular!) and the `package.json` referenced the plural form (`apollo-server-cloud-functions`): 724d9ff0#diff-e1d725fd66f7e9ef5251abf0437a09ca These references have been mostly fixed in the READMEs and supporting documentation, but the underlying monorepo directory structure has still not been fixed, which I'm sure contributed to this module being overlooked and unreferenced in the move to TypeScript project references in #1772. Additionally, the lack of referencing in the monorepo's TS config has resulted in it being broken in the most recent 2.2.0 release, as reported by @pyros2097 and @thetre97 in: #1896 (comment) This should fix that by properly adding the TypeScript project references.
…1948) * Add correct project references for `apollo-server-cloud-functions`. The `apollo-server-cloud-functions` has been been mis-referenced (or referenced inconsistently) since its original inception in #1446 when its package directory was `apollo-server-cloud-function` (singular!) and the `package.json` referenced the plural form (`apollo-server-cloud-functions`): 724d9ff0#diff-e1d725fd66f7e9ef5251abf0437a09ca These references have been mostly fixed in the READMEs and supporting documentation, but the underlying monorepo directory structure has still not been fixed, which I'm sure contributed to this module being overlooked and unreferenced in the move to TypeScript project references in #1772. Additionally, the lack of referencing in the monorepo's TS config has resulted in it being broken in the most recent 2.2.0 release, as reported by @pyros2097 and @thetre97 in: #1896 (comment) This should fix that by properly adding the TypeScript project references. * Sorting.
This PR adds support for Google Cloud Functions (based on the Lambda one), you can check out a minimal but working example at: https://europe-west1-test-project-bdb0d.cloudfunctions.net/test-apollo-server-cloud-function
This issue fixes #1402
TODO: