Skip to content
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

Serve API in a lambda #45

Merged
merged 22 commits into from
Apr 27, 2019
Merged

Conversation

lucasconstantino
Copy link
Collaborator

@lucasconstantino lucasconstantino commented Apr 13, 2019

Resolves #44

This is an implementation of the GraphQL API as lambda, deployed inside Netlify's own lambda management system.

The working solution can be accessed in the following addresses:

App: https://deploy-preview-45--dep-manager-web.netlify.com/
GraphQL Playground: https://deploy-preview-45--dep-manager-web.netlify.com/.netlify/functions/playground (please, access in incognito)

About GraphQL Playground:
You MUST set a GITHUB_OAUTH_TOKEN header on the Playground UI. You can get a valid token either by authenticating in the App and copying the Bida-App-Github-Token localStorage key, or by getting a Personal Access Token on GitHub. If you do the second, please give the following permissions to the token: read:gpg_key, read:org, read:public_key, read:repo_hook, repo, user

@lucasconstantino lucasconstantino changed the title Extract API to a dedicated backend Serve API in a lambda Apr 13, 2019
@lucasconstantino lucasconstantino force-pushed the issue/44--graphql-api-lambda branch 3 times, most recently from 49228d8 to aa2c8b4 Compare April 14, 2019 00:57
@lucasconstantino
Copy link
Collaborator Author

lucasconstantino commented Apr 15, 2019

This solves some issues from #42

@dannytce
Copy link

Overall looks solid. But I am going to rather bring someone from backend department to review it properly!

@behalka
Copy link

behalka commented Apr 17, 2019

hi @lucasconstantino I'm trying to access the playground but I get redirected to login (even if I grant access I still can't get there). If that's covered by your instructions then I don't get them I guess 😅

@lucasconstantino
Copy link
Collaborator Author

lucasconstantino commented Apr 17, 2019

Hey @behalka! Are we exchanging reviews here, or what? 😆

So, you actually got a bug I'm really confused about. What's going on here is that this application is a SPA, so all paths are redirected to the root /index.html path. This configuration is done on Netlify itself. The problem seems to be that Netlify has some special paths, like the ones for functions, which live under .netlify/functions/[name], but somehow the redirect rule for the SPA is messing with it's internal paths. That's probably a bug on their side, I'm going to fire an issue somewhere soon.

Now the confusing part: this issue seems to happen under specific browsers or contexts. For instance, I can actually access the playground if I use incognito mode in Chrome, or if I use Firefox 😱

Please, try to access it in Firefox or incognito, and report back to me if it does not work. I still don't know if it works only in my machine 🤔

Otherwise, I would recommend you clone the project to use it locally - which will trigger different server for the App and the API, meaning this issue won't occur.

src/lambda/graphql.ts Outdated Show resolved Hide resolved
@behalka
Copy link

behalka commented Apr 17, 2019

hey again @lucasconstantino - yeah it looks like that 😊

I got it working in the incognito mode so thanks a lot - also for the detailed explanation. I really appreciate that :)

@lucasconstantino lucasconstantino force-pushed the issue/44--graphql-api-lambda branch 2 times, most recently from 8cb5abe to c63096b Compare April 17, 2019 18:16
@lucasconstantino lucasconstantino force-pushed the issue/44--graphql-api-lambda branch from c63096b to 87df194 Compare April 17, 2019 18:57
@lucasconstantino lucasconstantino mentioned this pull request Apr 17, 2019
@lucasconstantino lucasconstantino force-pushed the issue/44--graphql-api-lambda branch from 5a8fb4e to febb57b Compare April 17, 2019 23:10
@lucasconstantino lucasconstantino changed the base branch from master to issue/42--bundle-analyzer April 17, 2019 23:20
@lucasconstantino lucasconstantino changed the base branch from issue/42--bundle-analyzer to master April 27, 2019 02:26
@lucasconstantino lucasconstantino force-pushed the issue/44--graphql-api-lambda branch from febb57b to 6171ba4 Compare April 27, 2019 02:27
@lucasconstantino lucasconstantino merged commit a8d7dbb into master Apr 27, 2019
@lucasconstantino lucasconstantino deleted the issue/44--graphql-api-lambda branch April 27, 2019 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants