Skip to content

Instantly share code, notes, and snippets.

View adrianhall's full-sized avatar

Adrian Hall adrianhall

View GitHub Profile
input GPSInput {
longitude: Float
latitude: Float
radius: Float
}
input AddressInput {
street: String
city: String
state: String
type Query {
me: User!
searchForLocation(byGPS: GPSInput, byAddress: AddressInput): LocationPagingConnection
}
type Mutation {
addLocation(location: LocationInput): Location
addReview(review: ReviewInput): Review
addFavorite(locationId: ID!): Location
}
input PagingRequest {
limit: Int
nextToken: String
}
type User {
id: ID!
name: String!
email: String
locations(paging: PagingRequest): LocationPagingConnection
type User {
id: ID!
name: String!
email: String
locations: [Location]
reviews: [Review]
favorites: [Location]
}
type Location {
const env = require('process').env;
const fetch = require('node-fetch');
const URL = require('url');
const AWS = require('aws-sdk');
AWS.config.update({
region: env.AWS_REGION,
credentials: new AWS.Credentials(env.AWS_ACCESS_KEY_ID, env.AWS_SECRET_ACCESS_KEY, env.AWS_SESSION_TOKEN)
});
provider:
name : aws
region : us-east-1
runtime : nodejs8.10
stage : ${opt:stage, 'dev'}
apiname : ${opt:apiname, 'chatql'}_${self:provider.stage}
environment:
GRAPHQL_API : { Fn::GetAtt: [ GraphQlApi, GraphQLUrl ] }
REGION : ${self:provider.region}
{
"version": "2017-02-28",
"operation": "PutItem",
"key": {
"userId": $util.dynamodb.toDynamoDBJson($ctx.args.userId)
},
"attributeValues": $util.dynamodb.toMapValuesJson($ctx.args.userDetails)
}
PostAuthenticationRole:
Type : AWS::IAM::Role
Properties:
RoleName : ${self:provider.apiname}-postauth-lambda
AssumeRolePolicyDocument:
Version : "2012-10-17"
Statement:
- Effect : Allow
Principal:
Service : lambda.amazonaws.com
AuthRole:
Type : AWS::IAM::Role
Description : "Role that the an authenticated user assumes"
Properties:
RoleName : ${self:provider.apiname}-auth
AssumeRolePolicyDocument:
Version : "2012-10-17"
Statement:
- Effect : Allow
Principal:
type User {
userId: ID!
name: String
}
input UserInput {
name: String
}
type UserPagedConnection {