How to create an Apollo GraphQL API with serverless

Link to chapter — https://serverless-stack.com/examples/how-to-create-an-apollo-graphql-api-with-serverless.html

Hello! thank you very much for this quick example.

Is it possible to setup the example to work within the ‘notes’ application examples. I’m trying to figure out the best way to pass along types to the resolvers for simple crud operations on a dynamodb table through apollo graphql, but am finding a number of issues just getting a simple resolver to grab input params and then composing t6he output correctly in typescript.

1 Like

Yeah we’ll expand this at some point. I’m not an expert in Apollo but what’s the problem you are having?

So I used this repo and was able to set it up.

But now my concern is as discussed in this the graphql-apollo is running server.createHandler inside only one function so isn’t it doing things in an unrecommended way?

Yeah there’s definitely a tradeoff here. The GraphQL approach usually fits things inside one function. I would still recommend making the function small. We have another example specifically on this coming up.

1 Like

So if we wanna make the function small then the only way it can be achieved is to have multiple graphql server?

I found a very similar discussion the slack of serverless-stack here
but still I am confused how to go about it, using a fat lambda is surely not a good way.

It really depends on how “fat” the Lambda is. There are ways to strip down the GraphQL server to make it a lot smaller. We’ll share more on this in the coming weeks.

1 Like

Thanks,
Though I have seen someone suggesting, here’s the discussion link that it’s okay to use one “fat” lambda to run apollo graphql server

@jayair i’m seeing this error following the guide directly:

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

can’t at all figure out how to fix it - any ideas? thanks v much

1 Like

Hello, just doing:

npm install graphql@15.0.0

works for me. Hope this helps you