Skip to content

Commit 46ef51a

Browse files
feat: add new scalar types for client type generation in GraphQL
1 parent 2d9c0f3 commit 46ef51a

File tree

2 files changed

+232
-0
lines changed

2 files changed

+232
-0
lines changed

playground-nuxt/app/graphql/sdk.ts

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
// THIS FILE IS GENERATED, DO NOT EDIT!
2+
/* eslint-disable eslint-comments/no-unlimited-disable */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
/* prettier-ignore */
6+
import * as Types from '#graphql-client';
7+
8+
export type CreateUserMutationVariables = Types.Exact<{
9+
input: Types.CreateUserInput;
10+
}>;
11+
12+
13+
export type CreateUserMutation = { __typename?: 'Mutation', createUser: { __typename?: 'User', id: string, name: string, email: string, createdAt: Date } };
14+
15+
export type AddTodoMutationVariables = Types.Exact<{
16+
title: Types.Scalars['String']['input'];
17+
}>;
18+
19+
20+
export type AddTodoMutation = { __typename?: 'Mutation', addTodo: { __typename?: 'Todo', id: string, title: string, completed: boolean, createdAt: Date } };
21+
22+
export type ToggleTodoMutationVariables = Types.Exact<{
23+
id: Types.Scalars['ID']['input'];
24+
}>;
25+
26+
27+
export type ToggleTodoMutation = { __typename?: 'Mutation', toggleTodo: { __typename?: 'Todo', id: string, title: string, completed: boolean, createdAt: Date } };
28+
29+
export type DeleteTodoMutationVariables = Types.Exact<{
30+
id: Types.Scalars['ID']['input'];
31+
}>;
32+
33+
34+
export type DeleteTodoMutation = { __typename?: 'Mutation', deleteTodo: boolean };
35+
36+
export type CreatePostMutationVariables = Types.Exact<{
37+
input: Types.CreatePostInput;
38+
}>;
39+
40+
41+
export type CreatePostMutation = { __typename?: 'Mutation', createPost: { __typename?: 'Post', id: string, title: string, content: string, authorId: string } };
42+
43+
export type AddCommentMutationVariables = Types.Exact<{
44+
input: Types.AddCommentInput;
45+
}>;
46+
47+
48+
export type AddCommentMutation = { __typename?: 'Mutation', addComment: { __typename?: 'Comment', id: string, content: string, postId: string, authorId: string } };
49+
50+
export type GetUsersQueryVariables = Types.Exact<{ [key: string]: never; }>;
51+
52+
53+
export type GetUsersQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string, name: string, email: string, createdAt: Date }> };
54+
55+
export type GetUserQueryVariables = Types.Exact<{
56+
id: Types.Scalars['ID']['input'];
57+
}>;
58+
59+
60+
export type GetUserQuery = { __typename?: 'Query', user?: { __typename?: 'User', id: string, name: string, email: string, createdAt: Date } | null };
61+
62+
export type GetTodosQueryVariables = Types.Exact<{ [key: string]: never; }>;
63+
64+
65+
export type GetTodosQuery = { __typename?: 'Query', todos: Array<{ __typename?: 'Todo', id: string, title: string, completed: boolean, createdAt: Date }> };
66+
67+
export type GetPostsQueryVariables = Types.Exact<{ [key: string]: never; }>;
68+
69+
70+
export type GetPostsQuery = { __typename?: 'Query', posts: Array<{ __typename?: 'Post', id: string, title: string, content: string, authorId: string }> };
71+
72+
export type GetPostWithCommentsQueryVariables = Types.Exact<{
73+
postId: Types.Scalars['ID']['input'];
74+
}>;
75+
76+
77+
export type GetPostWithCommentsQuery = { __typename?: 'Query', post?: { __typename?: 'Post', id: string, title: string, content: string, authorId: string } | null, comments: Array<{ __typename?: 'Comment', id: string, content: string, authorId: string }> };
78+
79+
80+
export const CreateUserDocument = /*#__PURE__*/ `
81+
mutation CreateUser($input: CreateUserInput!) {
82+
createUser(input: $input) {
83+
id
84+
name
85+
email
86+
createdAt
87+
}
88+
}
89+
`;
90+
export const AddTodoDocument = /*#__PURE__*/ `
91+
mutation AddTodo($title: String!) {
92+
addTodo(title: $title) {
93+
id
94+
title
95+
completed
96+
createdAt
97+
}
98+
}
99+
`;
100+
export const ToggleTodoDocument = /*#__PURE__*/ `
101+
mutation ToggleTodo($id: ID!) {
102+
toggleTodo(id: $id) {
103+
id
104+
title
105+
completed
106+
createdAt
107+
}
108+
}
109+
`;
110+
export const DeleteTodoDocument = /*#__PURE__*/ `
111+
mutation DeleteTodo($id: ID!) {
112+
deleteTodo(id: $id)
113+
}
114+
`;
115+
export const CreatePostDocument = /*#__PURE__*/ `
116+
mutation CreatePost($input: CreatePostInput!) {
117+
createPost(input: $input) {
118+
id
119+
title
120+
content
121+
authorId
122+
}
123+
}
124+
`;
125+
export const AddCommentDocument = /*#__PURE__*/ `
126+
mutation AddComment($input: AddCommentInput!) {
127+
addComment(input: $input) {
128+
id
129+
content
130+
postId
131+
authorId
132+
}
133+
}
134+
`;
135+
export const GetUsersDocument = /*#__PURE__*/ `
136+
query GetUsers {
137+
users {
138+
id
139+
name
140+
email
141+
createdAt
142+
}
143+
}
144+
`;
145+
export const GetUserDocument = /*#__PURE__*/ `
146+
query GetUser($id: ID!) {
147+
user(id: $id) {
148+
id
149+
name
150+
email
151+
createdAt
152+
}
153+
}
154+
`;
155+
export const GetTodosDocument = /*#__PURE__*/ `
156+
query GetTodos {
157+
todos {
158+
id
159+
title
160+
completed
161+
createdAt
162+
}
163+
}
164+
`;
165+
export const GetPostsDocument = /*#__PURE__*/ `
166+
query GetPosts {
167+
posts {
168+
id
169+
title
170+
content
171+
authorId
172+
}
173+
}
174+
`;
175+
export const GetPostWithCommentsDocument = /*#__PURE__*/ `
176+
query GetPostWithComments($postId: ID!) {
177+
post(id: $postId) {
178+
id
179+
title
180+
content
181+
authorId
182+
}
183+
comments(postId: $postId) {
184+
id
185+
content
186+
authorId
187+
}
188+
}
189+
`;
190+
export type Requester<C = {}> = <R, V>(doc: string, vars?: V, options?: C) => Promise<R> | AsyncIterable<R>
191+
export function getSdk<C>(requester: Requester<C>) {
192+
return {
193+
CreateUser(variables: Types.CreateUserMutationVariables, options?: C): Promise<Types.CreateUserMutation> {
194+
return requester<Types.CreateUserMutation, Types.CreateUserMutationVariables>(CreateUserDocument, variables, options) as Promise<Types.CreateUserMutation>;
195+
},
196+
AddTodo(variables: Types.AddTodoMutationVariables, options?: C): Promise<Types.AddTodoMutation> {
197+
return requester<Types.AddTodoMutation, Types.AddTodoMutationVariables>(AddTodoDocument, variables, options) as Promise<Types.AddTodoMutation>;
198+
},
199+
ToggleTodo(variables: Types.ToggleTodoMutationVariables, options?: C): Promise<Types.ToggleTodoMutation> {
200+
return requester<Types.ToggleTodoMutation, Types.ToggleTodoMutationVariables>(ToggleTodoDocument, variables, options) as Promise<Types.ToggleTodoMutation>;
201+
},
202+
DeleteTodo(variables: Types.DeleteTodoMutationVariables, options?: C): Promise<Types.DeleteTodoMutation> {
203+
return requester<Types.DeleteTodoMutation, Types.DeleteTodoMutationVariables>(DeleteTodoDocument, variables, options) as Promise<Types.DeleteTodoMutation>;
204+
},
205+
CreatePost(variables: Types.CreatePostMutationVariables, options?: C): Promise<Types.CreatePostMutation> {
206+
return requester<Types.CreatePostMutation, Types.CreatePostMutationVariables>(CreatePostDocument, variables, options) as Promise<Types.CreatePostMutation>;
207+
},
208+
AddComment(variables: Types.AddCommentMutationVariables, options?: C): Promise<Types.AddCommentMutation> {
209+
return requester<Types.AddCommentMutation, Types.AddCommentMutationVariables>(AddCommentDocument, variables, options) as Promise<Types.AddCommentMutation>;
210+
},
211+
GetUsers(variables?: Types.GetUsersQueryVariables, options?: C): Promise<Types.GetUsersQuery> {
212+
return requester<Types.GetUsersQuery, Types.GetUsersQueryVariables>(GetUsersDocument, variables, options) as Promise<Types.GetUsersQuery>;
213+
},
214+
GetUser(variables: Types.GetUserQueryVariables, options?: C): Promise<Types.GetUserQuery> {
215+
return requester<Types.GetUserQuery, Types.GetUserQueryVariables>(GetUserDocument, variables, options) as Promise<Types.GetUserQuery>;
216+
},
217+
GetTodos(variables?: Types.GetTodosQueryVariables, options?: C): Promise<Types.GetTodosQuery> {
218+
return requester<Types.GetTodosQuery, Types.GetTodosQueryVariables>(GetTodosDocument, variables, options) as Promise<Types.GetTodosQuery>;
219+
},
220+
GetPosts(variables?: Types.GetPostsQueryVariables, options?: C): Promise<Types.GetPostsQuery> {
221+
return requester<Types.GetPostsQuery, Types.GetPostsQueryVariables>(GetPostsDocument, variables, options) as Promise<Types.GetPostsQuery>;
222+
},
223+
GetPostWithComments(variables: Types.GetPostWithCommentsQueryVariables, options?: C): Promise<Types.GetPostWithCommentsQuery> {
224+
return requester<Types.GetPostWithCommentsQuery, Types.GetPostWithCommentsQueryVariables>(GetPostWithCommentsDocument, variables, options) as Promise<Types.GetPostWithCommentsQuery>;
225+
}
226+
};
227+
}
228+
export type Sdk = ReturnType<typeof getSdk>;

src/client-codegen.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ export async function generateClientTypes(
157157
strictScalars: true,
158158
scalars: {
159159
DateTime: 'Date',
160+
JSON: 'any',
161+
UUID: 'string',
162+
NonEmptyString: 'string',
163+
Currency: 'string',
160164
},
161165
},
162166
presetConfig: {

0 commit comments

Comments
 (0)