Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

WIP - Mongo Integration Initial Commit, works on localhost, not lambda #305

Closed
wants to merge 1 commit into from

Conversation

kvreem
Copy link

@kvreem kvreem commented Feb 2, 2018

In response to #260

WIP:

Issue No. 1 -

sls logs -f graphql -s production gives me the following error

MongoDB connection error. Please make sure MongoDb is running. { MongoError: failed to connect to server [undefined:27017] on first connect [MongoError: getaddrinfo ENOTFOUND undefined undefined:27017]

Issue No. 2 -
When I deploy to lambda, I get

Failed to load https://i1jaqo3pye.execute-api.us-west-1.amazonaws.com/production/graphql: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://runway.supply' is therefore not allowed access. The response had HTTP status code 502. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I tried on my visiting my cloud front url, and directly on the s3 endpoint that is http but always seeing this.

In Postman I enter the following query:

http://localhost:4000/graphql

{"query":"{\n getUserById(_id:\"5a5eb1dcc33a4d6706dbc344\"){\n _id }\n }\n"}

And here is the response:

{
    "data": {
        "getUserById": {
            "_id": "5a5eb1dcc33a4d6706dbc344"
        }
    }
}

Access-Control-Allow-Credentials →true
Access-Control-Allow-Origin →*
Connection →keep-alive
Content-Type →application/json
Date →Fri, 02 Feb 2018 08:28:13 GMT
cache-control →no-cache
content-length →59
vary →origin,accept-encoding

When I use my endpoint in lambda

{
    "message": "Internal server error"
}
Connection →keep-alive
Content-Length →36
Content-Type →application/json
Date →Fri, 02 Feb 2018 08:37:36 GMT
Via →1.1 e28ad9276c9737a09021d2f12e3a655d.cloudfront.net (CloudFront)
X-Amz-Cf-Id →_Xp6U6KOdq2F8n9nGUugm7zjH1DAj_KljjHDbogrCikNlvncQpgSpQ==
X-Cache →Error from cloudfront
x-amzn-RequestId →50aeaf77-07f4-11e8-aec4-bb55e63ef128

I can't tell if the cors issue and mongo connection issue are independent or is cors causing the failure to connect to mongo, or is my code the reason. I am using mongoose.

I left my development cluster in the config/mongo/security.env.local because i have mock data in it, leaving prod and local env files in config/mongo directory.

@sid88in
Copy link
Contributor

sid88in commented Feb 2, 2018

@kvreem Big thanks for creating this PR. Let's work on it together next week to iron out the issues. I'll play with it over the weekend.

@sid88in
Copy link
Contributor

sid88in commented Feb 6, 2018

@kvreem feel free to create fresh PR with your latest changes!

@sid88in sid88in closed this Feb 6, 2018
@kvreem
Copy link
Author

kvreem commented Feb 7, 2018

@sid88in yup thanks will do so this week ideally.

@sid88in
Copy link
Contributor

sid88in commented Feb 7, 2018

yay thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants