Skip to content

Commit

Permalink
Auto-generate graphql query and mutation strings (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrod-lowe authored Aug 25, 2024
1 parent ce84550 commit ac5b733
Show file tree
Hide file tree
Showing 11 changed files with 17,070 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ clean:
rm -f graphql/mutation/*/appsync.js
rm -f graphql/query/*/appsync.js
rm -rf graphql/node_modules
rm -f appsync/.graphqlconfig.yml
rm -rf appsync/node_modules
12 changes: 11 additions & 1 deletion appsync/appsync.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
appsync/graphql.ts: graphql/schema.graphql
if [ -z "$(IN_PIPELINE)" ] ; then \
docker run --rm -it --user $$(id -u):$$(id -g) -v $(PWD):/app -w /app/appsync --entrypoint ./node_modules/.bin/graphql-code-generator node:20 --config codegen.ts ; \
docker run --rm --user $$(id -u):$$(id -g) -v $(PWD):/app -w /app/appsync --entrypoint ./node_modules/.bin/graphql-code-generator node:20 --config codegen.ts ; \
else \
echo Not re-auto-generating types file in pipeline ; \
fi

appsync/make-schema.js: appsync/make-schema.ts
cd appsync ; esbuild make-schema.ts --bundle --format=esm --platform=node --target=esnext --sourcemap=inline --sources-content=false > make-schema.js

appsync/schema.ts: graphql/schema.graphql appsync/make-schema.js
if [ -z "$(IN_PIPELINE)" ] ; then \
docker run --rm -i --user $$(id -u):$$(id -g) -v $(PWD):/app -w /app/appsync node:20 ./make-schema.js < $< > $@ ; \
else \
echo Not re-auto-generating types file in pipeline ; \
fi
14 changes: 13 additions & 1 deletion appsync/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ const config: CodegenConfig = {
schema: "../graphql/schema.graphql",
generates: {
"graphql.ts": {
plugins: ["typescript"]
plugins: ["typescript"],
config: {
scalars: {
AWSTime: "string",
AWSDateTime: "string",
AWSTimestamp: "string",
AWSEmail: "string",
AWSJSON: "string",
AWSURL: "string",
AWSPhone: "string",
AWSIPAddress: "string",
}
}
}
}
};
Expand Down
9 changes: 8 additions & 1 deletion appsync/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ export type Scalars = {
Boolean: { input: boolean; output: boolean; }
Int: { input: number; output: number; }
Float: { input: number; output: number; }
AWSDateTime: { input: any; output: any; }
AWSDateTime: { input: string; output: string; }
AWSEmail: { input: string; output: string; }
AWSIPAddress: { input: string; output: string; }
AWSJSON: { input: string; output: string; }
AWSPhone: { input: string; output: string; }
AWSTime: { input: string; output: string; }
AWSTimestamp: { input: string; output: string; }
AWSURL: { input: string; output: string; }
};

export type CreateGameInput = {
Expand Down
Loading

0 comments on commit ac5b733

Please sign in to comment.