Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .changeset/@graphql-codegen_typescript-10764-dependencies.md

This file was deleted.

6 changes: 3 additions & 3 deletions examples/programmatic-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
"@graphql-codegen/core": "6.0.0",
"@graphql-codegen/plugin-helpers": "7.0.0",
"@graphql-codegen/typed-document-node": "7.0.0",
"@graphql-codegen/typescript": "6.0.0",
"@graphql-codegen/typescript-operations": "6.0.0",
"@graphql-codegen/typescript": "6.0.1",
"@graphql-codegen/typescript-operations": "6.0.1",
"@graphql-codegen/typescript-resolvers": "6.0.0",
"@graphql-tools/graphql-file-loader": "^8.1.12",
"@graphql-tools/load": "8.1.10",
"@graphql-tools/schema": "10.0.33",
"graphql": "16.13.2",
"graphql": "16.14.0",
"graphql-tag": "2.12.6",
"prettier": "3.8.3"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@graphql-typed-document-node/core": "3.2.0",
"graphql": "16.13.2"
"graphql": "16.14.0"
},
"devDependencies": {
"@graphql-codegen/cli": "7.0.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript-graphql-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test:end2end": "vitest --no-watch"
},
"dependencies": {
"graphql": "16.13.2",
"graphql": "16.14.0",
"graphql-request": "7.4.0",
"graphql-yoga": "5.21.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/typescript-resolvers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"test:end2end": "exit 0"
},
"dependencies": {
"graphql": "16.13.2",
"graphql": "16.14.0",
"graphql-yoga": "5.21.0"
},
"devDependencies": {
"@graphql-codegen/cli": "7.0.0",
"@graphql-codegen/typescript": "6.0.0",
"@graphql-codegen/typescript": "6.0.1",
"@graphql-codegen/typescript-resolvers": "6.0.0"
},
"bob": false
Expand Down
2 changes: 1 addition & 1 deletion examples/vite/vite-react-cts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@apollo/client": "^3.7.10",
"@graphql-typed-document-node/core": "3.2.0",
"@vitejs/plugin-react-swc": "^4.0.0",
"graphql": "16.13.2",
"graphql": "16.14.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"vite": "^8.0.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/vite/vite-react-mts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@apollo/client": "^3.7.10",
"@graphql-typed-document-node/core": "3.2.0",
"@vitejs/plugin-react-swc": "^4.0.0",
"graphql": "16.13.2",
"graphql": "16.14.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"vite": "^8.0.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/vite/vite-react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@apollo/client": "^3.7.10",
"@graphql-typed-document-node/core": "3.2.0",
"@vitejs/plugin-react-swc": "^4.0.0",
"graphql": "16.13.2",
"graphql": "16.14.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"vite": "^8.0.0"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
"bob-the-bundler": "7.0.1",
"eslint": "10.3.0",
"eslint-plugin-tailwindcss": "npm:@hasparus/eslint-plugin-tailwindcss@3.17.5",
"graphql": "16.13.2",
"graphql": "16.14.0",
"husky": "9.1.7",
"jest-diff": "30.3.0",
"lint-staged": "16.4.0",
"lint-staged": "17.0.2",
"memfs": "4.57.2",
"patch-package": "8.0.1",
"prettier": "3.8.3",
Expand Down
9 changes: 9 additions & 0 deletions packages/plugins/other/visitor-plugin-common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @graphql-codegen/visitor-plugin-common

## 7.0.1

### Patch Changes

- [#10781](https://github.com/dotansimha/graphql-code-generator/pull/10781)
[`5f035cb`](https://github.com/dotansimha/graphql-code-generator/commit/5f035cb40ac351fa0e5b098369d2a77da3cd2803)
Thanks [@eddeee888](https://github.com/eddeee888)! - Fix `const` enum applying `typesPrefix` and
`typesSuffix` incorrectly

## 7.0.0

### Major Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/other/visitor-plugin-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/visitor-plugin-common",
"version": "7.0.0",
"version": "7.0.1",
"type": "module",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const convertSchemaEnumToDeclarationBlockString = ({
convertName({
options: {
typesPrefix: naming.options.typesPrefix,
typesSuffix: naming.options.typesPrefix,
typesSuffix: naming.options.typesSuffix,
},
convert: () =>
naming.convert(enumOption, {
Expand Down
13 changes: 13 additions & 0 deletions packages/plugins/typescript/operations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @graphql-codegen/typescript-operations

## 6.0.1

### Patch Changes

- [#10781](https://github.com/dotansimha/graphql-code-generator/pull/10781)
[`5f035cb`](https://github.com/dotansimha/graphql-code-generator/commit/5f035cb40ac351fa0e5b098369d2a77da3cd2803)
Thanks [@eddeee888](https://github.com/eddeee888)! - Fix `const` enum applying `typesPrefix` and
`typesSuffix` incorrectly

- Updated dependencies
[[`5f035cb`](https://github.com/dotansimha/graphql-code-generator/commit/5f035cb40ac351fa0e5b098369d2a77da3cd2803)]:
- @graphql-codegen/visitor-plugin-common@7.0.1

## 6.0.0

### Major Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/typescript/operations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/typescript-operations",
"version": "6.0.0",
"version": "6.0.1",
"type": "module",
"description": "GraphQL Code Generator plugin for generating TypeScript types for GraphQL queries, mutations, subscriptions and fragments",
"repository": {
Expand Down Expand Up @@ -48,7 +48,7 @@
"dependencies": {
"@graphql-codegen/plugin-helpers": "^7.0.0",
"@graphql-codegen/schema-ast": "^6.0.0",
"@graphql-codegen/visitor-plugin-common": "^7.0.0",
"@graphql-codegen/visitor-plugin-common": "^7.0.1",
"auto-bind": "^5.0.0",
"tslib": "^2.8.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,65 @@ describe('TypeScript Operations Plugin - Enum', () => {
validateTs(result, undefined, undefined, undefined, undefined, true);
});

it('handles `native-numeric` enum with types prefix and suffix', async () => {
const schema = buildSchema(/* GraphQL */ `
type Query {
me: User
}

type User {
id: ID!
name: String!
role: UserRole!
createdAt: DateTime!
}

enum UserRole {
ADMIN
CUSTOMER
}

scalar DateTime
`);
const document = parse(/* GraphQL */ `
query Me($role: UserRole!) {
me {
id
}
}
`);

const result = mergeOutputs([
await plugin(
schema,
[{ document }],
{ enumType: 'native-numeric', typesPrefix: 'AA_', typesSuffix: '_ZZ' },
{ outputFile: '' },
),
]);

expect(result).toMatchInlineSnapshot(`
"/** Internal type. DO NOT USE DIRECTLY. */
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
/** Internal type. DO NOT USE DIRECTLY. */
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
export enum AA_UserRole_ZZ {
Admin_ZZ = 0,
Customer_ZZ = 1
}

export type AA_MeQueryVariables_ZZ = Exact<{
role: AA_UserRole_ZZ;
}>;


export type AA_MeQuery_ZZ = { me: { id: string } | null };
"
`);

validateTs(result, undefined, undefined, undefined, undefined, true);
});

it('handles `const` enum', async () => {
const schema = buildSchema(/* GraphQL */ `
type Query {
Expand Down Expand Up @@ -164,6 +223,72 @@ describe('TypeScript Operations Plugin - Enum', () => {
validateTs(result, undefined, undefined, undefined, undefined, true);
});

it('handles `const` enum with types prefix and suffix', async () => {
const schema = buildSchema(/* GraphQL */ `
type Query {
me: User
}

type User {
id: ID!
name: String!
role: UserRole!
createdAt: DateTime!
}

enum UserRole {
A_B_C
X_Y_Z
_TEST
My_Value
_123
}

scalar DateTime
`);
const document = parse(/* GraphQL */ `
query Me($role: UserRole!) {
me {
id
}
}
`);

const result = mergeOutputs([
await plugin(
schema,
[{ document }],
{ enumType: 'const', typesPrefix: 'AA_', typesSuffix: '_ZZ' },
{ outputFile: '' },
),
]);

expect(result).toMatchInlineSnapshot(`
"/** Internal type. DO NOT USE DIRECTLY. */
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
/** Internal type. DO NOT USE DIRECTLY. */
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
export const AA_UserRole_ZZ = {
AA_ABC_ZZ: 'A_B_C',
AA_XYZ_ZZ: 'X_Y_Z',
AA_Test_ZZ: '_TEST',
AA_MyValue_ZZ: 'My_Value',
AA_123_ZZ: '_123'
} as const;

export type AA_UserRole_ZZ = typeof AA_UserRole_ZZ[keyof typeof AA_UserRole_ZZ];
export type AA_MeQueryVariables_ZZ = Exact<{
role: AA_UserRole_ZZ;
}>;


export type AA_MeQuery_ZZ = { me: { id: string } | null };
"
`);

validateTs(result, undefined, undefined, undefined, undefined, true);
});

it('handles `native-const` enum', async () => {
const schema = buildSchema(/* GraphQL */ `
type Query {
Expand Down
13 changes: 13 additions & 0 deletions packages/plugins/typescript/typescript/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @graphql-codegen/typescript

## 6.0.1

### Patch Changes

- [#10764](https://github.com/dotansimha/graphql-code-generator/pull/10764)
[`c95db26`](https://github.com/dotansimha/graphql-code-generator/commit/c95db264be92090ae593f3ca22010e42668dc813)
Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:
- Updated dependency [`tslib@~2.8.0` ↗︎](https://www.npmjs.com/package/tslib/v/2.8.0) (from
`~2.6.0`, in `dependencies`)
- Updated dependencies
[[`5f035cb`](https://github.com/dotansimha/graphql-code-generator/commit/5f035cb40ac351fa0e5b098369d2a77da3cd2803)]:
- @graphql-codegen/visitor-plugin-common@7.0.1

## 6.0.0

### Major Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/typescript/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/typescript",
"version": "6.0.0",
"version": "6.0.1",
"type": "module",
"description": "GraphQL Code Generator plugin for generating TypeScript types",
"repository": {
Expand Down Expand Up @@ -42,7 +42,7 @@
"dependencies": {
"@graphql-codegen/plugin-helpers": "^7.0.0",
"@graphql-codegen/schema-ast": "^6.0.0",
"@graphql-codegen/visitor-plugin-common": "^7.0.0",
"@graphql-codegen/visitor-plugin-common": "^7.0.1",
"auto-bind": "^5.0.0",
"tslib": "~2.8.0"
},
Expand Down
6 changes: 3 additions & 3 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@graphql-codegen/schema-ast": "6.0.0",
"@graphql-codegen/time": "7.0.0",
"@graphql-codegen/typed-document-node": "7.0.0",
"@graphql-codegen/typescript": "6.0.0",
"@graphql-codegen/typescript": "6.0.1",
"@graphql-codegen/typescript-apollo-angular": "5.0.1",
"@graphql-codegen/typescript-apollo-client-helpers": "4.0.1",
"@graphql-codegen/typescript-generic-sdk": "5.0.1",
Expand All @@ -44,7 +44,7 @@
"@graphql-codegen/typescript-mongodb": "4.0.2",
"@graphql-codegen/typescript-msw": "4.0.1",
"@graphql-codegen/typescript-nhost": "1.0.1",
"@graphql-codegen/typescript-operations": "6.0.0",
"@graphql-codegen/typescript-operations": "6.0.1",
"@graphql-codegen/typescript-react-apollo": "4.4.2",
"@graphql-codegen/typescript-react-query": "4.1.0",
"@graphql-codegen/typescript-resolvers": "6.0.0",
Expand All @@ -64,7 +64,7 @@
"classnames": "2.5.1",
"date-fns": "4.1.0",
"dedent": "1.7.2",
"graphql": "16.13.2",
"graphql": "16.14.0",
"js-yaml": "4.1.1",
"next": "14.2.35",
"next-mdx-remote": "6.0.0",
Expand Down
Loading
Loading