

- #NPM SERVERLESS GRAPHQL APOLLO INSTALL#
- #NPM SERVERLESS GRAPHQL APOLLO MANUAL#
- #NPM SERVERLESS GRAPHQL APOLLO CODE#
#NPM SERVERLESS GRAPHQL APOLLO CODE#
Apollo Server also mocks our schema by default, so the initial setup of our GraphQL server is very compact - there is not much code needed at all to get started.Īssuming we are in a fresh project folder. GraphQL comes with a default UI, the grahiQL client, which gives us the possibility to inspect a schema and to request data from an API. You should have run aws configure and setup your local machine with the AWS Access Key ID and AWS Secret Access Key from an IAM user with privileges to access DynamoDB. You should have an AWS Account and the AWS cli installed. The server-side implementation with Apollo is also very straightforward and they offer an AWS Lambda compatible package, apollo-server-lambda, which we are going to use in this tutorial.



Apollo Client now fully supports React Hooks which is one of the reasons I love using it. This installs a global cli tool which can be invoked by serverless or sls.Īs a GraphQL server we are using Apollo, which is also one of the most famous graqhql clients and servers.
#NPM SERVERLESS GRAPHQL APOLLO INSTALL#
Therefore we should install the serverless cli globally using npm install -g serverless.
#NPM SERVERLESS GRAPHQL APOLLO MANUAL#
To make our lives easier we are going to leverage the serverless framework for automating our deploys, so we can just define our deployment configuration in a serverless.yml file and don't need to worry about manual deployment. Other famous examples providers are Azure Functions, Google Cloud Functions and Cloudflare Workers. There are multiple providers for serverless functions, but the biggest and most famous one is AWS Lambda. Serverless might not be the answer for all our problems but an GraphQL server seems like a great use case, so let's dive right in. Faster development: We don't have to deal with managing, installing and configuring servers, or with deployment processes, so we can just focus on the business logic and building our app.Infinite Scaling: We don't have to deal with infrastructure or servers, so when our requests suddenly goes from 0 to 1000s of requests per second, it won't be a problem because the serverless api will scale automatically for us.So while we develop our app, we have close to zero costs, and depending on how it develops it will scale automatically when traffic increases. Pay as you go: We have zero initial costs and pay only for what we actually use.What are the advantages of a serverless api?
