Skip to content

Commit

Permalink
Auto-generate graphql types
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrod-lowe committed Aug 24, 2024
1 parent 42439d5 commit 89b5fee
Show file tree
Hide file tree
Showing 10 changed files with 5,466 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ graphql/node_modules
graphql/mutation/*/appsync.js
graphql/query/*/appsync.js
graphql/coverage/

appsync/node_modules
appsync/.graphqlconfig.yml
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RW_ROLE = arn:aws:iam::$(ACCOUNT_ID):role/GitHubAction-Wildsea-rw-dev
all: $(TERRAFOM_VALIDATE)

include graphql/graphql.mk
include appsync/appsync.mk

.PHONY: terraform-format
terraform-format: $(addprefix terraform-format-environment-,$(TERRAFORM_ENVIRONMENTS)) $(addprefix terraform-format-module-,$(TERRAFORM_MODULES))
Expand Down Expand Up @@ -62,3 +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
6 changes: 6 additions & 0 deletions appsync/appsync.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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 ; \
else \
echo Not re-auto-generating types file in pipeline
fi
14 changes: 14 additions & 0 deletions appsync/codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
overwrite: true,
schema: "../graphql/schema.graphql",
generates: {
"graphql.ts": {
plugins: ["typescript"]
}
}
};

export default config;
54 changes: 54 additions & 0 deletions appsync/graphql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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]> };
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: { input: string; output: string; }
String: { input: string; output: string; }
Boolean: { input: boolean; output: boolean; }
Int: { input: number; output: number; }
Float: { input: number; output: number; }
AWSDateTime: { input: any; output: any; }
};

export type CreateGameInput = {
description?: InputMaybe<Scalars['String']['input']>;
name: Scalars['String']['input'];
};

export type Game = {
__typename?: 'Game';
createdAt: Scalars['AWSDateTime']['output'];
description?: Maybe<Scalars['String']['output']>;
fireflyUserId: Scalars['ID']['output'];
id: Scalars['ID']['output'];
name: Scalars['String']['output'];
players?: Maybe<Array<Scalars['ID']['output']>>;
privateNotes?: Maybe<Scalars['String']['output']>;
publicNotes?: Maybe<Scalars['String']['output']>;
updatedAt: Scalars['AWSDateTime']['output'];
};

export type Mutation = {
__typename?: 'Mutation';
createGame: Game;
};


export type MutationCreateGameArgs = {
input: CreateGameInput;
};

export type Query = {
__typename?: 'Query';
getGame: Game;
};


export type QueryGetGameArgs = {
id: Scalars['ID']['input'];
};
Loading

0 comments on commit 89b5fee

Please sign in to comment.