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
8 changes: 4 additions & 4 deletions examples/programmatic-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"dependencies": {
"@graphql-codegen/core": "5.0.0",
"@graphql-codegen/plugin-helpers": "6.0.0",
"@graphql-codegen/typed-document-node": "6.0.0",
"@graphql-codegen/typescript": "5.0.0",
"@graphql-codegen/typescript-operations": "5.0.0",
"@graphql-codegen/typescript-resolvers": "5.0.0",
"@graphql-codegen/typed-document-node": "6.0.1",
"@graphql-codegen/typescript": "5.0.1",
"@graphql-codegen/typescript-operations": "5.0.1",
"@graphql-codegen/typescript-resolvers": "5.0.1",
"@graphql-tools/graphql-file-loader": "8.0.1",
"@graphql-tools/load": "8.1.0",
"@graphql-tools/schema": "10.0.6",
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 @@ -4,8 +4,8 @@
"private": true,
"devDependencies": {
"@graphql-codegen/cli": "6.0.0",
"@graphql-codegen/typescript": "5.0.0",
"@graphql-codegen/typescript-resolvers": "5.0.0"
"@graphql-codegen/typescript": "5.0.1",
"@graphql-codegen/typescript-resolvers": "5.0.1"
},
"dependencies": {
"graphql": "16.9.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/plugins/other/visitor-plugin-common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @graphql-codegen/visitor-plugin-common

## 6.0.1

### Patch Changes

- [#10412](https://github.com/dotansimha/graphql-code-generator/pull/10412) [`accdab6`](https://github.com/dotansimha/graphql-code-generator/commit/accdab69106605241933e9d66d64dc7077656f30) Thanks [@thekevinbrown](https://github.com/thekevinbrown)! - Add special handling for identifiers that consist entirely of _ characters when transformUnderscore is true. This prevents _ values in GraphQL enums from being emitted without identifers in the resulting types.

## 6.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": "6.0.0",
"version": "6.0.1",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ export interface RawTypesConfig extends RawConfig {
directiveArgumentAndInputFieldMappingTypeSuffix?: string;
}

const onlyUnderscoresPattern = /^_+$/;

export class BaseTypesVisitor<
TRawConfig extends RawTypesConfig = RawTypesConfig,
TPluginConfig extends ParsedTypesConfig = ParsedTypesConfig
Expand Down Expand Up @@ -903,7 +905,9 @@ export class BaseTypesVisitor<
const optionName = this.makeValidEnumIdentifier(
this.convertName(enumOption, {
useTypesPrefix: false,
transformUnderscore: true,
// We can only strip out the underscores if the value contains other
// characters. Otherwise we'll generate syntactically invalid code.
transformUnderscore: !onlyUnderscoresPattern.test(enumOption.name.value),
})
);
const comment = this.getNodeComment(enumOption);
Expand Down
7 changes: 7 additions & 0 deletions packages/plugins/typescript/document-nodes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @graphql-codegen/typescript-document-nodes

## 5.0.1

### Patch Changes

- Updated dependencies [[`accdab6`](https://github.com/dotansimha/graphql-code-generator/commit/accdab69106605241933e9d66d64dc7077656f30)]:
- @graphql-codegen/[email protected]

## 5.0.0

### Major Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/typescript/document-nodes/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/typescript-document-nodes",
"version": "5.0.0",
"version": "5.0.1",
"description": "GraphQL Code Generator plugin for generating TypeScript modules with embedded GraphQL document nodes",
"repository": {
"type": "git",
Expand All @@ -14,7 +14,7 @@
},
"dependencies": {
"@graphql-codegen/plugin-helpers": "^6.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.1",
"auto-bind": "~4.0.0",
"tslib": "~2.6.0"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/plugins/typescript/gql-tag-operations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @graphql-codegen/gql-tag-operations

## 5.0.1

### Patch Changes

- Updated dependencies [[`accdab6`](https://github.com/dotansimha/graphql-code-generator/commit/accdab69106605241933e9d66d64dc7077656f30)]:
- @graphql-codegen/[email protected]

## 5.0.0

### Major Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/typescript/gql-tag-operations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/gql-tag-operations",
"version": "5.0.0",
"version": "5.0.1",
"description": "GraphQL Code Generator plugin for generating a typed gql tag function",
"repository": {
"type": "git",
Expand All @@ -18,7 +18,7 @@
"dependencies": {
"@graphql-tools/utils": "^10.0.0",
"@graphql-codegen/plugin-helpers": "^6.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.1",
"auto-bind": "~4.0.0",
"tslib": "~2.6.0"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/plugins/typescript/operations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @graphql-codegen/typescript-operations

## 5.0.1

### Patch Changes

- Updated dependencies [[`accdab6`](https://github.com/dotansimha/graphql-code-generator/commit/accdab69106605241933e9d66d64dc7077656f30)]:
- @graphql-codegen/[email protected]
- @graphql-codegen/[email protected]

## 5.0.0

### Major Changes
Expand Down
6 changes: 3 additions & 3 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": "5.0.0",
"version": "5.0.1",
"description": "GraphQL Code Generator plugin for generating TypeScript types for GraphQL queries, mutations, subscriptions and fragments",
"repository": {
"type": "git",
Expand All @@ -14,8 +14,8 @@
},
"dependencies": {
"@graphql-codegen/plugin-helpers": "^6.0.0",
"@graphql-codegen/typescript": "^5.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.0",
"@graphql-codegen/typescript": "^5.0.1",
"@graphql-codegen/visitor-plugin-common": "6.0.1",
"auto-bind": "~4.0.0",
"tslib": "~2.6.0"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/plugins/typescript/resolvers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @graphql-codegen/typescript-resolvers

## 5.0.1

### Patch Changes

- Updated dependencies [[`accdab6`](https://github.com/dotansimha/graphql-code-generator/commit/accdab69106605241933e9d66d64dc7077656f30)]:
- @graphql-codegen/[email protected]
- @graphql-codegen/[email protected]

## 5.0.0

### Major Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/plugins/typescript/resolvers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/typescript-resolvers",
"version": "5.0.0",
"version": "5.0.1",
"description": "GraphQL Code Generator plugin for generating TypeScript types for resolvers signature",
"repository": {
"type": "git",
Expand All @@ -14,8 +14,8 @@
},
"dependencies": {
"@graphql-codegen/plugin-helpers": "^6.0.0",
"@graphql-codegen/typescript": "^5.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.0",
"@graphql-codegen/typescript": "^5.0.1",
"@graphql-codegen/visitor-plugin-common": "6.0.1",
"@graphql-tools/utils": "^10.0.0",
"auto-bind": "~4.0.0",
"tslib": "~2.6.0"
Expand Down
7 changes: 7 additions & 0 deletions packages/plugins/typescript/typed-document-node/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @graphql-codegen/typed-document-node

## 6.0.1

### Patch Changes

- Updated dependencies [[`accdab6`](https://github.com/dotansimha/graphql-code-generator/commit/accdab69106605241933e9d66d64dc7077656f30)]:
- @graphql-codegen/[email protected]

## 6.0.0

### Major Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/typescript/typed-document-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/typed-document-node",
"version": "6.0.0",
"version": "6.0.1",
"description": "GraphQL Code Generator plugin for generating ready-to-use TypedDocumentNode based on GraphQL operations",
"repository": {
"type": "git",
Expand All @@ -18,7 +18,7 @@
"dependencies": {
"change-case-all": "1.0.15",
"@graphql-codegen/plugin-helpers": "^6.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.1",
"auto-bind": "~4.0.0",
"tslib": "~2.6.0"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/plugins/typescript/typescript/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @graphql-codegen/typescript

## 5.0.1

### Patch Changes

- Updated dependencies [[`accdab6`](https://github.com/dotansimha/graphql-code-generator/commit/accdab69106605241933e9d66d64dc7077656f30)]:
- @graphql-codegen/[email protected]

## 5.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": "5.0.0",
"version": "5.0.1",
"description": "GraphQL Code Generator plugin for generating TypeScript types",
"repository": {
"type": "git",
Expand All @@ -15,7 +15,7 @@
"dependencies": {
"@graphql-codegen/plugin-helpers": "^6.0.0",
"@graphql-codegen/schema-ast": "^5.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.1",
"auto-bind": "~4.0.0",
"tslib": "~2.6.0"
},
Expand Down
20 changes: 19 additions & 1 deletion packages/plugins/typescript/typescript/tests/typescript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe('TypeScript', () => {
}`);
});

it('Should removed underscore from enum values', async () => {
it('Should remove underscore from enum values', async () => {
const schema = buildSchema(/* GraphQL */ `
enum MyEnum {
A_B_C
Expand All @@ -213,6 +213,24 @@ describe('TypeScript', () => {
}`);
});

it('Should leave underscores in enum values when the value is only underscores', async () => {
const schema = buildSchema(/* GraphQL */ `
enum MyEnum {
_
__
_TEST
}
`);
const result = await plugin(schema, [], {}, { outputFile: '' });

expect(result.content).toBeSimilarStringTo(`
export enum MyEnum {
_ = '_',
__ = '__',
Test = '_TEST'
}`);
});

it('Should work with enum as const', async () => {
const schema = buildSchema(/* GraphQL */ `
enum MyEnum {
Expand Down
11 changes: 11 additions & 0 deletions packages/presets/client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @graphql-codegen/client-preset

## 5.0.2

### Patch Changes

- Updated dependencies [[`accdab6`](https://github.com/dotansimha/graphql-code-generator/commit/accdab69106605241933e9d66d64dc7077656f30)]:
- @graphql-codegen/[email protected]
- @graphql-codegen/[email protected]
- @graphql-codegen/[email protected]
- @graphql-codegen/[email protected]
- @graphql-codegen/[email protected]

## 5.0.1

### Patch Changes
Expand Down
12 changes: 6 additions & 6 deletions packages/presets/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/client-preset",
"version": "5.0.1",
"version": "5.0.2",
"description": "GraphQL Code Generator preset for client.",
"repository": {
"type": "git",
Expand All @@ -21,12 +21,12 @@
"@babel/helper-plugin-utils": "^7.20.2",
"@babel/template": "^7.20.7",
"@graphql-codegen/add": "^6.0.0",
"@graphql-codegen/typed-document-node": "^6.0.0",
"@graphql-codegen/typescript": "^5.0.0",
"@graphql-codegen/typescript-operations": "^5.0.0",
"@graphql-codegen/gql-tag-operations": "5.0.0",
"@graphql-codegen/typed-document-node": "^6.0.1",
"@graphql-codegen/typescript": "^5.0.1",
"@graphql-codegen/typescript-operations": "^5.0.1",
"@graphql-codegen/gql-tag-operations": "5.0.1",
"@graphql-codegen/plugin-helpers": "^6.0.0",
"@graphql-codegen/visitor-plugin-common": "^6.0.0",
"@graphql-codegen/visitor-plugin-common": "^6.0.1",
"@graphql-typed-document-node/core": "3.2.0",
"@graphql-tools/documents": "^1.0.0",
"@graphql-tools/utils": "^10.0.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/presets/graphql-modules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @graphql-codegen/graphql-modules-preset

## 5.0.2

### Patch Changes

- Updated dependencies [[`accdab6`](https://github.com/dotansimha/graphql-code-generator/commit/accdab69106605241933e9d66d64dc7077656f30)]:
- @graphql-codegen/[email protected]

## 5.0.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/presets/graphql-modules/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/graphql-modules-preset",
"version": "5.0.1",
"version": "5.0.2",
"description": "GraphQL Code Generator preset for modularized schema",
"repository": {
"type": "git",
Expand All @@ -16,7 +16,7 @@
},
"dependencies": {
"@graphql-codegen/plugin-helpers": "^6.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.0",
"@graphql-codegen/visitor-plugin-common": "6.0.1",
"@graphql-tools/utils": "^10.0.0",
"parse-filepath": "^1.0.2",
"change-case-all": "1.0.15",
Expand Down
10 changes: 5 additions & 5 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@graphql-codegen/c-sharp": "4.3.1",
"@graphql-codegen/c-sharp-operations": "2.3.1",
"@graphql-codegen/cli": "6.0.0",
"@graphql-codegen/client-preset": "5.0.1",
"@graphql-codegen/client-preset": "5.0.2",
"@graphql-codegen/core": "5.0.0",
"@graphql-codegen/flow": "2.3.6",
"@graphql-codegen/flow-operations": "2.3.6",
Expand All @@ -46,8 +46,8 @@
"@graphql-codegen/near-operation-file-preset": "2.5.0",
"@graphql-codegen/schema-ast": "5.0.0",
"@graphql-codegen/time": "6.0.0",
"@graphql-codegen/typed-document-node": "6.0.0",
"@graphql-codegen/typescript": "5.0.0",
"@graphql-codegen/typed-document-node": "6.0.1",
"@graphql-codegen/typescript": "5.0.1",
"@graphql-codegen/typescript-apollo-angular": "3.5.6",
"@graphql-codegen/typescript-apollo-client-helpers": "2.2.6",
"@graphql-codegen/typescript-generic-sdk": "3.1.0",
Expand All @@ -56,10 +56,10 @@
"@graphql-codegen/typescript-mongodb": "2.4.6",
"@graphql-codegen/typescript-msw": "3.0.1",
"@graphql-codegen/typescript-nhost": "0.0.3",
"@graphql-codegen/typescript-operations": "5.0.0",
"@graphql-codegen/typescript-operations": "5.0.1",
"@graphql-codegen/typescript-react-apollo": "3.3.7",
"@graphql-codegen/typescript-react-query": "4.1.0",
"@graphql-codegen/typescript-resolvers": "5.0.0",
"@graphql-codegen/typescript-resolvers": "5.0.1",
"@graphql-codegen/typescript-rtk-query": "2.4.1",
"@graphql-codegen/typescript-stencil-apollo": "2.3.6",
"@graphql-codegen/typescript-type-graphql": "2.3.6",
Expand Down
Loading