@@ -14,8 +14,18 @@ const schema = buildSchema(`
14
14
authors: [Author]
15
15
}
16
16
17
+ type Request {
18
+ id: ID!
19
+ }
20
+
21
+ type CancelRequestResponse {
22
+ request: Request
23
+ error: String
24
+ }
25
+
17
26
type Mutation {
18
27
createAuthor: Author!
28
+ cancelRequest(id: ID!): CancelRequestResponse!
19
29
}
20
30
21
31
schema {
@@ -96,14 +106,52 @@ import { TypedDocumentNode } from "@graphql-typed-document-node/core";
96
106
export type AuthorsQueryVariables = Exact<{ [key: string]: never; }>;
97
107
98
108
99
- export type AuthorsQuery = { __typename?: 'Query', authors?: Array<{ __typename?: 'Author', idField: string } | null | undefined > | null | undefined };
109
+ export type AuthorsQuery = { __typename?: 'Query', authors?: Array<{ __typename?: 'Author', idField: string } | null> | null };
100
110
101
111
export const authors: TypedDocumentNode<AuthorsQuery, AuthorsQueryVariables>;
102
112
export default authors;
103
113
` . trimStart ( )
104
114
) ;
105
115
} ) ;
106
116
117
+ it ( "should have default export for another single mutation document" , async ( ) => {
118
+ const mutationDocument = parse ( `
119
+ mutation CancelRequest($id: ID!) {
120
+ cancelRequest(id: $id) {
121
+ request {
122
+ id
123
+ }
124
+
125
+ error
126
+ }
127
+ }
128
+ ` ) ;
129
+
130
+ const document = {
131
+ document : mutationDocument ,
132
+ location : "createAuthors.gql" ,
133
+ } ;
134
+
135
+ const config = getConfig ( { documents : [ document ] } ) ;
136
+ const output = await codegen ( config ) ;
137
+
138
+ expect ( output ) . toBe (
139
+ `
140
+ import { TypedDocumentNode } from "@graphql-typed-document-node/core";
141
+
142
+ export type CancelRequestMutationVariables = Exact<{
143
+ id: Scalars['ID'];
144
+ }>;
145
+
146
+
147
+ export type CancelRequestMutation = { __typename?: 'Mutation', cancelRequest: { __typename?: 'CancelRequestResponse', error?: string | null, request?: { __typename?: 'Request', id: string } | null } };
148
+
149
+ export const CancelRequest: TypedDocumentNode<CancelRequestMutation, CancelRequestMutationVariables>;
150
+ export default CancelRequest;
151
+ ` . trimStart ( )
152
+ ) ;
153
+ } ) ;
154
+
107
155
it ( "should have default export for a single mutation document" , async ( ) => {
108
156
const mutationDocument = parse ( `
109
157
mutation createAuthor {
@@ -175,12 +223,12 @@ import { TypedDocumentNode } from "@graphql-typed-document-node/core";
175
223
export type AuthorsQueryVariables = Exact<{ [key: string]: never; }>;
176
224
177
225
178
- export type AuthorsQuery = { __typename?: 'Query', authors?: Array<{ __typename?: 'Author', idField: string } | null | undefined > | null | undefined };
226
+ export type AuthorsQuery = { __typename?: 'Query', authors?: Array<{ __typename?: 'Author', idField: string } | null> | null };
179
227
180
228
export type AlsoAuthorsQueryVariables = Exact<{ [key: string]: never; }>;
181
229
182
230
183
- export type AlsoAuthorsQuery = { __typename?: 'Query', authors?: Array<{ __typename?: 'Author', idField: string } | null | undefined > | null | undefined };
231
+ export type AlsoAuthorsQuery = { __typename?: 'Query', authors?: Array<{ __typename?: 'Author', idField: string } | null> | null };
184
232
185
233
export type CreateAuthorMutationVariables = Exact<{ [key: string]: never; }>;
186
234
0 commit comments