Skip to content

Commit

Permalink
work on book auctions architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
sehrish30 committed May 23, 2023
1 parent 5b03ba7 commit 550a2d3
Show file tree
Hide file tree
Showing 19 changed files with 3,986 additions and 118 deletions.
Binary file modified .DS_Store
Binary file not shown.
111 changes: 111 additions & 0 deletions books-service/appsync.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
AWSDate: string;
AWSDateTime: string;
AWSEmail: string;
AWSIPAddress: string;
AWSJSON: string;
AWSPhone: string;
AWSTime: string;
AWSTimestamp: number;
AWSURL: string;
};

export type Book = {
__typename?: 'Book';
author: Scalars['String'];
bookId: Scalars['ID'];
createdAt: Scalars['AWSDateTime'];
description?: Maybe<Scalars['String']>;
imageUrl?: Maybe<Scalars['AWSURL']>;
price: Scalars['Float'];
title: Scalars['String'];
updatedAt: Scalars['AWSDateTime'];
};

export type BookInput = {
author: Scalars['String'];
description?: InputMaybe<Scalars['String']>;
imageUrl?: InputMaybe<Scalars['AWSURL']>;
price: Scalars['Float'];
title: Scalars['String'];
};

export type BooksPage = {
__typename?: 'BooksPage';
books?: Maybe<Array<Maybe<Book>>>;
nextToken?: Maybe<Scalars['String']>;
};

export type Mutation = {
__typename?: 'Mutation';
createBook: Book;
createOrder: Scalars['Boolean'];
};


export type MutationCreateBookArgs = {
newBook?: InputMaybe<BookInput>;
};


export type MutationCreateOrderArgs = {
newOrder?: InputMaybe<OrderInput>;
};

export type OrderInput = {
items?: InputMaybe<Array<InputMaybe<OrderItemInput>>>;
};

export type OrderItem = {
__typename?: 'OrderItem';
book: Book;
orderId: Scalars['ID'];
quantity: Scalars['Int'];
userId: Scalars['ID'];
};

export type OrderItemInput = {
bookId: Scalars['ID'];
quantity: Scalars['Int'];
};

export type OrderItemsPage = {
__typename?: 'OrderItemsPage';
OrderItems?: Maybe<Array<Maybe<OrderItem>>>;
nextToken?: Maybe<Scalars['String']>;
};

export type Query = {
__typename?: 'Query';
getBookById: Book;
listBooks: BooksPage;
myOrders: OrderItemsPage;
};


export type QueryGetBookByIdArgs = {
bookId: Scalars['ID'];
};


export type QueryListBooksArgs = {
limit: Scalars['Int'];
nextToken?: InputMaybe<Scalars['String']>;
};


export type QueryMyOrdersArgs = {
limit: Scalars['Int'];
nextToken?: InputMaybe<Scalars['String']>;
};
9 changes: 9 additions & 0 deletions books-service/appsync.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
scalar AWSDate
scalar AWSTime
scalar AWSDateTime
scalar AWSTimestamp
scalar AWSEmail
scalar AWSJSON
scalar AWSURL
scalar AWSPhone
scalar AWSIPAddress
23 changes: 23 additions & 0 deletions books-service/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
overwrite: true

schema:
- schema.graphql
- appsync.graphql # 👈 add this

generates:
appsync.d.ts:
plugins:
- typescript

# and this 👇
config:
scalars:
AWSJSON: string
AWSDate: string
AWSTime: string
AWSDateTime: string
AWSTimestamp: number
AWSEmail: string
AWSURL: string
AWSPhone: string
AWSIPAddress: string
18 changes: 0 additions & 18 deletions books-service/handler.js

This file was deleted.

16 changes: 16 additions & 0 deletions books-service/mapping-templates/Mutation.createBook.request.vtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version" : "2017-02-28",
"operation" : "PutItem",
"key": {
"bookId" : $util.dynamodb.toDynamoDBJson($util.autoId())
},
"attributeValues" : {
"Title" : $util.dynamodb.toDynamoDBJson($ctx.args.newBook.title),
"Description": $util.dynamodb.toDynamoDBJson($ctx.args.newBook.description),
"ImageUrl": $util.dynamodb.toDynamoDBJson($ctx.args.newBook.imageUrl),
"Author": $util.dynamodb.toDynamoDBJson($ctx.args.newBook.author),
"Price": $util.dynamodb.toDynamoDBJson($ctx.args.newBook.price),
"CreatedAt": $util.dynamodb.toDynamoDBJson($util.time.nowISO8601()),
"UpdatedAt": $util.dynamodb.toDynamoDBJson($util.time.nowISO8601())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$util.toJson($ctx.result)
7 changes: 7 additions & 0 deletions books-service/mapping-templates/Query.getBookById.request.vtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version" : "2017-02-28",
"operation" : "GetItem",
"key" : {
"BookId" : $util.dynamodb.toDynamoDBJson($ctx.args.bookId)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$util.toJson($ctx.result)
6 changes: 6 additions & 0 deletions books-service/mapping-templates/Query.listBooks.request.vtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version" : "2017-02-28",
"operation" : "Scan",
"limit" : $util.toJson($context.arguments.limit),
"nextToken" : $util.toJson($context.arguments.nextToken)
}
4 changes: 4 additions & 0 deletions books-service/mapping-templates/Query.listBooks.response.vtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"books": $util.toJson($context.result.items),
"nextToken": $util.toJson($util.defaultIfNullOrBlank($context.result.nextToken, null))
}
Loading

0 comments on commit 550a2d3

Please sign in to comment.