Skip to content

Commit f895551

Browse files
committed
updated document and example
1 parent 292bc77 commit f895551

File tree

3 files changed

+44
-29
lines changed

3 files changed

+44
-29
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ generates:
2626
# You can put the config for typescript plugin here
2727
# see: https://www.graphql-code-generator.com/plugins/typescript
2828
strictScalars: true
29+
# Overrides built-in ID scalar to both input and output types as string.
30+
# see: https://the-guild.dev/graphql/codegen/plugins/typescript/typescript#scalars
31+
scalars:
32+
ID: string
2933
# You can also write the config for this plugin together
3034
schema: yup # or zod
3135
```

codegen.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ generates:
44
example/types.ts:
55
plugins:
66
- typescript
7+
config:
8+
scalars:
9+
ID: string
710
example/yup/schemas.ts:
811
plugins:
912
- ./dist/main/index.js:
@@ -38,6 +41,8 @@ generates:
3841
max: ['max', '$1 + 1']
3942
exclusiveMin: min
4043
exclusiveMax: max
44+
scalars:
45+
ID: string
4146
example/zod/schemas.ts:
4247
plugins:
4348
- ./dist/main/index.js:
@@ -59,6 +64,8 @@ generates:
5964
startsWith: ['regex', '/^$1/', 'message']
6065
format:
6166
email: email
67+
scalars:
68+
ID: string
6269
example/myzod/schemas.ts:
6370
plugins:
6471
- ./dist/main/index.js:
@@ -72,3 +79,5 @@ generates:
7279
startsWith: ['pattern', '/^$1/']
7380
format:
7481
email: email
82+
scalars:
83+
ID: string

example/types.ts

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@ export type InputMaybe<T> = Maybe<T>;
33
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
44
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
55
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
6+
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
7+
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
68
/** All built-in and custom scalars, mapped to their actual values */
79
export type Scalars = {
8-
ID: string;
9-
String: string;
10-
Boolean: boolean;
11-
Int: number;
12-
Float: number;
13-
Date: any;
14-
URL: any;
10+
ID: { input: string; output: string; }
11+
String: { input: string; output: string; }
12+
Boolean: { input: boolean; output: boolean; }
13+
Int: { input: number; output: number; }
14+
Float: { input: number; output: number; }
15+
Date: { input: any; output: any; }
16+
URL: { input: any; output: any; }
1517
};
1618

1719
export type Admin = {
1820
__typename?: 'Admin';
19-
lastModifiedAt?: Maybe<Scalars['Date']>;
21+
lastModifiedAt?: Maybe<Scalars['Date']['output']>;
2022
};
2123

2224
export type AttributeInput = {
23-
key?: InputMaybe<Scalars['String']>;
24-
val?: InputMaybe<Scalars['String']>;
25+
key?: InputMaybe<Scalars['String']['input']>;
26+
val?: InputMaybe<Scalars['String']['input']>;
2527
};
2628

2729
export enum ButtonComponentType {
@@ -33,7 +35,7 @@ export type ComponentInput = {
3335
child?: InputMaybe<ComponentInput>;
3436
childrens?: InputMaybe<Array<InputMaybe<ComponentInput>>>;
3537
event?: InputMaybe<EventInput>;
36-
name: Scalars['String'];
38+
name: Scalars['String']['input'];
3739
type: ButtonComponentType;
3840
};
3941

@@ -43,8 +45,8 @@ export type DropDownComponentInput = {
4345
};
4446

4547
export type EventArgumentInput = {
46-
name: Scalars['String'];
47-
value: Scalars['String'];
48+
name: Scalars['String']['input'];
49+
value: Scalars['String']['input'];
4850
};
4951

5052
export type EventInput = {
@@ -59,12 +61,12 @@ export enum EventOptionType {
5961

6062
export type Guest = {
6163
__typename?: 'Guest';
62-
lastLoggedIn?: Maybe<Scalars['Date']>;
64+
lastLoggedIn?: Maybe<Scalars['Date']['output']>;
6365
};
6466

6567
export type HttpInput = {
6668
method?: InputMaybe<HttpMethod>;
67-
url: Scalars['URL'];
69+
url: Scalars['URL']['input'];
6870
};
6971

7072
export enum HttpMethod {
@@ -78,16 +80,16 @@ export type LayoutInput = {
7880

7981
export type PageInput = {
8082
attributes?: InputMaybe<Array<AttributeInput>>;
81-
date?: InputMaybe<Scalars['Date']>;
82-
height: Scalars['Float'];
83-
id: Scalars['ID'];
83+
date?: InputMaybe<Scalars['Date']['input']>;
84+
height: Scalars['Float']['input'];
85+
id: Scalars['ID']['input'];
8486
layout: LayoutInput;
8587
pageType: PageType;
86-
postIDs?: InputMaybe<Array<Scalars['ID']>>;
87-
show: Scalars['Boolean'];
88-
tags?: InputMaybe<Array<InputMaybe<Scalars['String']>>>;
89-
title: Scalars['String'];
90-
width: Scalars['Int'];
88+
postIDs?: InputMaybe<Array<Scalars['ID']['input']>>;
89+
show: Scalars['Boolean']['input'];
90+
tags?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
91+
title: Scalars['String']['input'];
92+
width: Scalars['Int']['input'];
9193
};
9294

9395
export enum PageType {
@@ -99,13 +101,13 @@ export enum PageType {
99101

100102
export type User = {
101103
__typename?: 'User';
102-
createdAt?: Maybe<Scalars['Date']>;
103-
email?: Maybe<Scalars['String']>;
104-
id?: Maybe<Scalars['ID']>;
104+
createdAt?: Maybe<Scalars['Date']['output']>;
105+
email?: Maybe<Scalars['String']['output']>;
106+
id?: Maybe<Scalars['ID']['output']>;
105107
kind?: Maybe<UserKind>;
106-
name?: Maybe<Scalars['String']>;
107-
password?: Maybe<Scalars['String']>;
108-
updatedAt?: Maybe<Scalars['Date']>;
108+
name?: Maybe<Scalars['String']['output']>;
109+
password?: Maybe<Scalars['String']['output']>;
110+
updatedAt?: Maybe<Scalars['Date']['output']>;
109111
};
110112

111113
export type UserKind = Admin | Guest;

0 commit comments

Comments
 (0)