-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
exclude_paths: | ||
- "graphql/mutation/*/appsync.js" | ||
- "graphql/query/*/appsync.js" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"root": true} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ override.tf.json | |
# Ignore CLI configuration files | ||
.terraformrc | ||
terraform.rc | ||
|
||
.validate | ||
.apply | ||
plan.tfplan |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import globals from "globals"; | ||
import pluginJs from "@eslint/js"; | ||
import tseslint from "typescript-eslint"; | ||
|
||
|
||
export default [ | ||
{files: ["**/*.{js,mjs,cjs,ts}"]}, | ||
{languageOptions: { globals: {...globals.browser, ...globals.node} }}, | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.recommended, | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
graphql/%/appsync.js: graphql/node_modules graphql/%/appsync.ts | ||
cd graphql && \ | ||
esbuild $*/*.ts \ | ||
--bundle \ | ||
--external:"@aws-appsync/utils" \ | ||
--format=esm \ | ||
--platform=node \ | ||
--target=esnext \ | ||
--sourcemap=inline \ | ||
--sources-content=false \ | ||
--outdir=$* | ||
|
||
graphql/node_modules: graphql/package.json | ||
cd graphql && npm install | ||
|
||
GRAPHQL := $(patsubst %.ts,%.js,$(wildcard graphql/*/*/appsync.ts)) | ||
|
||
.PHONY: graphql | ||
graphql: $(GRAPHQL) | ||
echo $(GRAPHQL) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { util, Context, DynamoDBPutItemRequest, AppSyncIdentityCognito, PutItemInputAttributeMap } from '@aws-appsync/utils'; | ||
|
||
/** | ||
* A CreateGameInput creates a Game. | ||
* They are stored in DynamoDB with a PK of `GAME#<id>` and an SK of `GAME`. | ||
* The ID is a UUID | ||
* The fireflyUserId is the Cognito ID of the user | ||
*/ | ||
|
||
interface CreateGameInput { | ||
name: string; | ||
description?: string; | ||
} | ||
|
||
export function request(context: Context<{ input: CreateGameInput }>): DynamoDBPutItemRequest { | ||
if (!context.identity) { | ||
util.error('Unauthorized: Identity information is missing.' as string); | ||
} | ||
|
||
const identity = context.identity as AppSyncIdentityCognito; | ||
if (!identity.sub) { | ||
util.error('Unauthorized: User ID is missing.' as string); | ||
} | ||
|
||
const input = context.arguments.input; | ||
const id = util.autoId(); | ||
const timestamp = util.time.nowISO8601(); | ||
return { | ||
operation: 'PutItem', | ||
key: util.dynamodb.toMapValues({ PK: "GAME#"+id, SK: 'GAME' }), | ||
attributeValues: util.dynamodb.toMapValues({ | ||
name: input.name, | ||
description: input.description, | ||
id: id, | ||
fireflyUserId: identity.sub, | ||
createdAt: timestamp, | ||
updatedAt: timestamp | ||
}) as PutItemInputAttributeMap | ||
}; | ||
} | ||
|
||
export function response(context: Context): unknown { | ||
if (context.error) { | ||
util.appendError(context.error.message, context.error.type, context.result); | ||
return; | ||
} | ||
return context.result; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.