Giter Site home page Giter Site logo

appsync-example-dynamodb's Introduction

AppSync Example w/ DynamoDB

MIT License

Deploy a GraphQL API using AWS AppSync, Serverless Application Model, and DynamoDB.
Based on appsync-example-lambda and appsync-resolvers.

Schema

type Person {
	id: ID!
	name: String!
	age: Int!
	birthday: String!

	friends: [Person!]!
}

type Query {
	people: [Person!]!
	person(id: ID!): Person
}

type Mutation {
	personCreate(name: String!, birthday: String!): Person!
	personFriendsAdd(person: ID, friend: ID!): Person!
}

schema {
	query: Query
	mutation: Mutation
}

Usage

Deployment

# Create S3 Bucket for CloudFormation Artifacts
$ > AWS_PROFILE=your-profile-name \
    make configure

# Build, Package, and Deploy the CloudFormation Stack
$ > AWS_PROFILE=your-profile-name \
    make build package deploy

API Access

# Print GraphQL API Endoint
$ > AWS_PROFILE=your-profile-name \
    make outputs-GraphQL

https://tdk6mhrty7ii.appsync-api.eu-central-1.amazonaws.com/graphql

# Print AppSync API Key
$ > AWS_PROFILE=your-profile-name \
    make outputs-APIKey

da2-1jdf4nmbwpsdr4vfxcxfza

Example

Query

$ > curl \
    -XPOST https://tdk6mhrty7ii.appsync-api.eu-central-1.amazonaws.com/graphql \
    -H "Content-Type:application/graphql" \
    -H "x-api-key:da2-1jdf4nmbwpsdr4vfxcxfza" \
    -d '{ "query": "query { people { name } }" }' | jq

Mutation

$ > curl \
    -XPOST https://tdk6mhrty7ii.appsync-api.eu-central-1.amazonaws.com/graphql \
    -H "Content-Type:application/graphql" \
    -H "x-api-key:da2-1jdf4nmbwpsdr4vfxcxfza" \
    -d '{ "query": "mutation { personCreate(name:\"Gregory Valdes\", birthday:\"1975-10-04T00:00:00Z\") { id } }" }' | jq

$ > curl \
    -XPOST https://tdk6mhrty7ii.appsync-api.eu-central-1.amazonaws.com/graphql \
    -H "Content-Type:application/graphql" \
    -H "x-api-key:da2-1jdf4nmbwpsdr4vfxcxfza" \
    -d '{ "query": "mutation { personCreate(name:\"Alejandro Manno\", birthday:\"1962-03-23T00:00:00Z\") { id } }" }' | jq

$ > curl \
    -XPOST https://tdk6mhrty7ii.appsync-api.eu-central-1.amazonaws.com/graphql \
    -H "Content-Type:application/graphql" \
    -H "x-api-key:da2-1jdf4nmbwpsdr4vfxcxfza" \
    -d '{ "query": "mutation { personFriendsAdd( person: "b5b2d08e …", friend: "467551bb …" ) { id friends { id } } }" }' | jq

Resolvers

  • Query.people
  • Query.person
  • Field.person.age (Lambda)
  • Field.person.friends
  • Mutation.personCreate
  • Mutation.personFriendsAdd

License

Feel free to use the code, it's released using the MIT license.

Contribution

You are welcome to contribute to this project! 😘

To make sure you have a pleasant experience, please read the code of conduct. It outlines core values and beliefs and will make working together a happier experience.

appsync-example-dynamodb's People

Contributors

sbstjn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

appsync-example-dynamodb's Issues

Running stories-app locally

How to do this ?

cd stories-app
npm install
npm start

but

Compiled with problems:X

ERROR in ./src/fonts.css (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-loader/dist/cjs.js!./src/fonts.css) 5:36-93

Module not found: Error: Can't resolve 'nunito/Nunito-Regular_new.ttf' in '/Users/jhw/work/unofficial-duolingo-stories/stories-app/src'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.