Skip to content

Commit bb32f2f

Browse files
committed
Update dependencies
1 parent eb82465 commit bb32f2f

File tree

5 files changed

+1462
-1405
lines changed

5 files changed

+1462
-1405
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ import { TypedDocumentNode } from "@graphql-typed-document-node/core";
8181
export type AuthorsQueryVariables = Exact<{ [key: string]: never; }>;
8282
8383
84-
export type AuthorsQuery = { authors?: Array<{ idField: string } | null | undefined> | null | undefined };
84+
export type AuthorsQuery = { authors?: Array<{ idField: string } | null> | null };
8585
8686
export const authors: TypedDocumentNode<AuthorsQuery, AuthorsQueryVariables>;
8787
export default authors;

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@
2121
"test": "jest"
2222
},
2323
"dependencies": {
24-
"@graphql-codegen/visitor-plugin-common": "^1.13.3",
24+
"@graphql-codegen/visitor-plugin-common": "^3.0.1",
2525
"pascal-case": "^3.1.1"
2626
},
2727
"peerDependencies": {
28-
"@graphql-typed-document-node/core": "^3.1.0",
28+
"@graphql-typed-document-node/core": "^3.1.2",
2929
"graphql": ">=14.6.0"
3030
},
3131
"devDependencies": {
32-
"@graphql-codegen/add": "^2.0.2",
33-
"@graphql-codegen/cli": "^1.19.4",
34-
"@graphql-codegen/core": "^1.17.9",
35-
"@graphql-codegen/plugin-helpers": "^1.18.2",
36-
"@graphql-codegen/typescript": "^1.19.0",
37-
"@graphql-codegen/typescript-operations": "^2.1.6",
32+
"@graphql-codegen/add": "^4.0.1",
33+
"@graphql-codegen/cli": "^3.2.1",
34+
"@graphql-codegen/core": "^3.1.0",
35+
"@graphql-codegen/plugin-helpers": "^4.0.0",
36+
"@graphql-codegen/typescript": "^3.0.1",
37+
"@graphql-codegen/typescript-operations": "^3.0.1",
3838
"@types/jest": "^26.0.19",
3939
"@types/node": "^14.14.14",
4040
"@types/react": "^17.0.0",

src/__tests__/plugin.test.ts

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@ const schema = buildSchema(`
1414
authors: [Author]
1515
}
1616
17+
type Request {
18+
id: ID!
19+
}
20+
21+
type CancelRequestResponse {
22+
request: Request
23+
error: String
24+
}
25+
1726
type Mutation {
1827
createAuthor: Author!
28+
cancelRequest(id: ID!): CancelRequestResponse!
1929
}
2030
2131
schema {
@@ -96,14 +106,52 @@ import { TypedDocumentNode } from "@graphql-typed-document-node/core";
96106
export type AuthorsQueryVariables = Exact<{ [key: string]: never; }>;
97107
98108
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 };
100110
101111
export const authors: TypedDocumentNode<AuthorsQuery, AuthorsQueryVariables>;
102112
export default authors;
103113
`.trimStart()
104114
);
105115
});
106116

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+
107155
it("should have default export for a single mutation document", async () => {
108156
const mutationDocument = parse(`
109157
mutation createAuthor {
@@ -175,12 +223,12 @@ import { TypedDocumentNode } from "@graphql-typed-document-node/core";
175223
export type AuthorsQueryVariables = Exact<{ [key: string]: never; }>;
176224
177225
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 };
179227
180228
export type AlsoAuthorsQueryVariables = Exact<{ [key: string]: never; }>;
181229
182230
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 };
184232
185233
export type CreateAuthorMutationVariables = Exact<{ [key: string]: never; }>;
186234

src/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const plugin: PluginFunction<UserConfig> = (_schema, documents, {}) => {
3535
'import { TypedDocumentNode } from "@graphql-typed-document-node/core";\n',
3636
]
3737
: [],
38-
content: output.join("\n\n"),
38+
content,
3939
};
4040
};
4141

0 commit comments

Comments
 (0)