serverless-cqrs
  • Introduction
  • Quickstart
  • Domain
  • Testing
  • Examples
    • Express
    • GraphQL
  • Advanced
    • Adapter Interface
      • Write Model
      • Read Model
    • Deploy
    • Authorization
    • Eventual Consistency
    • Multiple Aggregates
  • Components
    • serverless-cqrs
    • write-model
      • repositoryBuilder
      • commandServiceBuilder
    • read-model
    • memory-adapter
    • dynamodb-adapter
    • elasticsearch-adapter
Powered by GitBook
On this page

Was this helpful?

  1. Examples

GraphQL

PreviousExpressNextAdapter Interface

Last updated 5 years ago

Was this helpful?

Description

First, make sure you've run npm i -g serverless and added your .

Deploying for the first time can take 10-20 minutes since it needs to create the ElasticSearch instance. If there is an error, you may get ROLLBACK_IN_PROGRESS the next time you try to deploy. Give it a few minutes and then try again.

git clone git@github.com:serverless-cqrs/graphql-example.git
cd graphql-example
npm i
serverless deploy

Once deployed, navigate to the returned endpoint url and you'll see the graphql playground, where you can run the following queries:

mutation {
  addTodo(id: "123", title: "Get Milk")
}
query {
  getById(id: "123") {
    id
    todos {
      title
      completed
    }
  }
}

The AWS Free Tier covers most of these services, but running an ElasticSearch instance on AWS can be expensive. Make sure to run serverless remove once you're done.

Open in GitHub
AWS credentials