-
-
Notifications
You must be signed in to change notification settings - Fork 677
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
Using this in a serverless environment (e.g. apollo-lambda-server) #96
Comments
Discussion copied from #52
OK. I saw that in the code above, however I get the following error when I try and use the global scoped metadata. I've confirmed that I am only including
@darbio The problem is that the metadata is attached to global scope to make multi-packages work but AWS lambda use the same node.js process for each request, so consecutive schema builds effect in duplicated types&resolvers definition. Storing built schema in global fix that + save time that would be used to build the schema for each request. global.schema = global.schema || buildSchemaSync(/*... */);
const schema = global.schema; According to your error, you need to make sure that there's no duplicated |
There are no duplicated I have tried Any other tips to try? |
Without error-reproducible code repository I'm not able to figure out what's wrong from this amount of informations. |
@19majkel94 here is a reproducible code example: https://github.com/darbio/example-type-graphql-serverless |
I think the problem may be with webpack - it doesn't play nicely with graphql. Removing graphql from webpack appears to solve the problem. I've updated the repo to reflect this. |
So, what is the solution for this now? |
@lookapanda Use the |
I did, it did not help, I still get the same error. |
|
Ah, I had to set my project's |
@lookapanda Yes, TypeGraphQL has a direct dependency on I think in future release I will reexport everything from |
Sorry for the newb question, @19majkel94 but what do you mean when you're talking about defining the schema globally? Do you mean just define it outside of the handler? This code doesn't compile for me:
I tried something like this Global.ts:
And in my handler:
But I still get: |
You need to define custom property in Or just cast it to any: (global as any).schema = (global as any).schema || await buildSchema(/*... */);
const schema = (global as any).schema; |
Hi, So i'm trying to do this (run on apollo-server-lambda) and I have this error: The first request works fine but the subsequent doesn't. I store the schema on global has shown above and I use the same version of graphql than type-graphql. Any ideas ? Thanks |
My graphql version is same in type-graphql and in the project:
package-lock for type-graphql
I have also added the following text in app.ts
I don't have graphql installed globally. I have also added to the package.json
Still I am getting the error:
|
You need to flatten your dependencies - And try |
@19majkel94 thanks for telling me the solution. Your suggestion also worked perfectly. You should write a medium article on it and even write this solution in the readme. |
@suku-h |
This solved my issues when running type-graphql with |
I had this problem not too long ago. In my case, it was happening because I wasn't properly excluding the node_modules folder from webpack. Once I did, the 'realm' error went away. |
What helped me with running |
This worked for me with apollo-server-lambda:
|
I was having this issue when running locally with the latest version of serverless-offline and after some digging this solved the issue for me, posting here incase it helps anyone else :-) |
I am getting below error in lambda(14.x) consistently:
Does anybody aware of this one? [Note: everything works as expected with |
@RishikeshDarandale +1 |
@98sean98 , my issue happens when the If it is set to |
@RishikeshDarandale @98sean98 I'm facing the same issue as well:
|
@omar-dulaimi , if you are using |
@RishikeshDarandale Yeah that does solve the issue, thanks. However, I was hoping to keep the sourcemaps. So not sure what the real issue here is. |
How would I use this library in a lambda execution model?
I tried to implement it as follows, but on the second (and subsequent) calls to the endpoint, I get an error which states:
I assume that this is because the schema is being re-built on every request, and therefore creating duplicated types?
handler.ts
person.ts:
peopleController.ts
The text was updated successfully, but these errors were encountered: