Skip to content

Commit c1861d2

Browse files
authored
fix: generated code use given name (#1103)
1 parent c3559e5 commit c1861d2

File tree

89 files changed

+1195
-761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1195
-761
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const Name = `Atlas`
2+
3+
export type Name = 'Atlas'

examples/$/generated-clients/atlas/modules/Global.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import type * as Data from './Data.js'
2+
13
import type { Index } from './SchemaIndex.js'
24

35
declare global {
46
export namespace GraffleGlobalTypes {
57
export interface Schemas {
68
Atlas: {
7-
name: 'Atlas'
9+
name: Data.Name
810
index: Index
911
customScalars: {}
1012
featureOptions: {

examples/$/generated-clients/atlas/modules/SchemaBuildtime.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,42 @@ import type * as $Scalar from './Scalar.ts'
66
// ------------------------------------------------------------ //
77

88
export namespace Root {
9-
export type Query = $.Object$2<'Query', {
9+
export type Query = $.Output.ObjectQuery<{
1010
continent: $.Field<
1111
$.Output.Nullable<Object.Continent>,
1212
$.Args<{
13-
code: $Scalar.ID
14-
}>
13+
code: $.Input.Field<$Scalar.ID>
14+
}, false>
1515
>
1616
continents: $.Field<
1717
$.Output.List<Object.Continent>,
1818
$.Args<{
19-
filter: $.Input.Nullable<InputObject.ContinentFilterInput>
20-
}>
19+
filter: $.Input.Field<$.Input.Nullable<InputObject.ContinentFilterInput>>
20+
}, true>
2121
>
2222
countries: $.Field<
2323
$.Output.List<Object.Country>,
2424
$.Args<{
25-
filter: $.Input.Nullable<InputObject.CountryFilterInput>
26-
}>
25+
filter: $.Input.Field<$.Input.Nullable<InputObject.CountryFilterInput>>
26+
}, true>
2727
>
2828
country: $.Field<
2929
$.Output.Nullable<Object.Country>,
3030
$.Args<{
31-
code: $Scalar.ID
32-
}>
31+
code: $.Input.Field<$Scalar.ID>
32+
}, false>
3333
>
3434
language: $.Field<
3535
$.Output.Nullable<Object.Language>,
3636
$.Args<{
37-
code: $Scalar.ID
38-
}>
37+
code: $.Input.Field<$Scalar.ID>
38+
}, false>
3939
>
4040
languages: $.Field<
4141
$.Output.List<Object.Language>,
4242
$.Args<{
43-
filter: $.Input.Nullable<InputObject.LanguageFilterInput>
44-
}>
43+
filter: $.Input.Field<$.Input.Nullable<InputObject.LanguageFilterInput>>
44+
}, true>
4545
>
4646
}>
4747
}
@@ -60,27 +60,27 @@ export namespace Enum {
6060

6161
export namespace InputObject {
6262
export type ContinentFilterInput = $.InputObject<'ContinentFilterInput', {
63-
code: $.Input.Nullable<InputObject.StringQueryOperatorInput>
64-
}>
63+
code: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
64+
}, true>
6565

6666
export type CountryFilterInput = $.InputObject<'CountryFilterInput', {
67-
code: $.Input.Nullable<InputObject.StringQueryOperatorInput>
68-
continent: $.Input.Nullable<InputObject.StringQueryOperatorInput>
69-
currency: $.Input.Nullable<InputObject.StringQueryOperatorInput>
70-
name: $.Input.Nullable<InputObject.StringQueryOperatorInput>
71-
}>
67+
code: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
68+
continent: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
69+
currency: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
70+
name: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
71+
}, true>
7272

7373
export type LanguageFilterInput = $.InputObject<'LanguageFilterInput', {
74-
code: $.Input.Nullable<InputObject.StringQueryOperatorInput>
75-
}>
74+
code: $.Input.Field<$.Input.Nullable<InputObject.StringQueryOperatorInput>>
75+
}, true>
7676

7777
export type StringQueryOperatorInput = $.InputObject<'StringQueryOperatorInput', {
78-
eq: $.Input.Nullable<$Scalar.String>
79-
in: $.Input.Nullable<$.Input.List<$Scalar.String>>
80-
ne: $.Input.Nullable<$Scalar.String>
81-
nin: $.Input.Nullable<$.Input.List<$Scalar.String>>
82-
regex: $.Input.Nullable<$Scalar.String>
83-
}>
78+
eq: $.Input.Field<$.Input.Nullable<$Scalar.String>>
79+
in: $.Input.Field<$.Input.Nullable<$.Input.List<$Scalar.String>>>
80+
ne: $.Input.Field<$.Input.Nullable<$Scalar.String>>
81+
nin: $.Input.Field<$.Input.Nullable<$.Input.List<$Scalar.String>>>
82+
regex: $.Input.Field<$.Input.Nullable<$Scalar.String>>
83+
}, true>
8484
}
8585

8686
// ------------------------------------------------------------ //
@@ -115,8 +115,8 @@ export namespace Object {
115115
name: $.Field<
116116
$Scalar.String,
117117
$.Args<{
118-
lang: $.Input.Nullable<$Scalar.String>
119-
}>
118+
lang: $.Input.Field<$.Input.Nullable<$Scalar.String>>
119+
}, true>
120120
>
121121
native: $.Field<$Scalar.String, null>
122122
phone: $.Field<$Scalar.String, null>

examples/$/generated-clients/atlas/modules/SchemaIndex.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
/* eslint-disable */
22

3+
import type * as Data from './Data.js'
4+
35
import type * as Schema from './SchemaBuildtime.js'
46

57
export interface Index {
6-
name: 'Atlas'
8+
name: Data.Name
79
RootTypesPresent: ['Query']
10+
RootUnion: Schema.Root.Query
811
Root: {
912
Query: Schema.Root.Query
1013
Mutation: null

examples/$/generated-clients/atlas/modules/SchemaRuntime.ts

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
/* eslint-disable */
22

33
import * as $ from '../../../../../src/entrypoints/schema.js'
4+
import * as Data from './Data.js'
45
import * as $Scalar from './Scalar.js'
6+
import type { Index } from './SchemaIndex.js'
57

68
export const $defaultSchemaUrl = new URL('https://countries.trevorblades.com/graphql')
79

810
export const ContinentFilterInput = $.InputObject(`ContinentFilterInput`, {
9-
code: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
10-
})
11+
code: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
12+
}, true)
1113

1214
export const CountryFilterInput = $.InputObject(`CountryFilterInput`, {
13-
code: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
14-
continent: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
15-
currency: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
16-
name: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
17-
})
15+
code: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
16+
continent: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
17+
currency: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
18+
name: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
19+
}, true)
1820

1921
export const LanguageFilterInput = $.InputObject(`LanguageFilterInput`, {
20-
code: $.Input.field(() => $.Input.Nullable(StringQueryOperatorInput)),
21-
})
22+
code: $.Input.Field(() => $.Input.Nullable(StringQueryOperatorInput)),
23+
}, true)
2224

2325
export const StringQueryOperatorInput = $.InputObject(`StringQueryOperatorInput`, {
24-
eq: $.Input.field($.Input.Nullable($Scalar.String)),
25-
in: $.Input.field($.Input.Nullable($.Input.List($Scalar.String))),
26-
ne: $.Input.field($.Input.Nullable($Scalar.String)),
27-
nin: $.Input.field($.Input.Nullable($.Input.List($Scalar.String))),
28-
regex: $.Input.field($.Input.Nullable($Scalar.String)),
29-
})
26+
eq: $.Input.Field($.Input.Nullable($Scalar.String)),
27+
in: $.Input.Field($.Input.Nullable($.Input.List($Scalar.String))),
28+
ne: $.Input.Field($.Input.Nullable($Scalar.String)),
29+
nin: $.Input.Field($.Input.Nullable($.Input.List($Scalar.String))),
30+
regex: $.Input.Field($.Input.Nullable($Scalar.String)),
31+
}, true)
3032

3133
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
3234
export const Continent = $.Object$(`Continent`, {
@@ -49,7 +51,7 @@ export const Country = $.Object$(`Country`, {
4951
emojiU: $.field($Scalar.String),
5052
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
5153
languages: $.field($.Output.List(() => Language)),
52-
name: $.field($Scalar.String, $.Args({ lang: $.Input.Nullable($Scalar.String) })),
54+
name: $.field($Scalar.String, $.Args({ lang: $.Input.Field($.Input.Nullable($Scalar.String)) }, true)),
5355
native: $.field($Scalar.String),
5456
phone: $.field($Scalar.String),
5557
phones: $.field($.Output.List($Scalar.String)),
@@ -85,22 +87,32 @@ export const Subdivision = $.Object$(`Subdivision`, {
8587
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
8688
export const Query = $.Object$(`Query`, {
8789
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
88-
continent: $.field($.Output.Nullable(() => Continent), $.Args({ code: $Scalar.ID })),
90+
continent: $.field($.Output.Nullable(() => Continent), $.Args({ code: $.Input.Field($Scalar.ID) }, false)),
8991
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
90-
continents: $.field($.Output.List(() => Continent), $.Args({ filter: $.Input.Nullable(ContinentFilterInput) })),
92+
continents: $.field(
93+
$.Output.List(() => Continent),
94+
$.Args({ filter: $.Input.Field($.Input.Nullable(ContinentFilterInput)) }, true),
95+
),
9196
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
92-
countries: $.field($.Output.List(() => Country), $.Args({ filter: $.Input.Nullable(CountryFilterInput) })),
97+
countries: $.field(
98+
$.Output.List(() => Country),
99+
$.Args({ filter: $.Input.Field($.Input.Nullable(CountryFilterInput)) }, true),
100+
),
93101
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
94-
country: $.field($.Output.Nullable(() => Country), $.Args({ code: $Scalar.ID })),
102+
country: $.field($.Output.Nullable(() => Country), $.Args({ code: $.Input.Field($Scalar.ID) }, false)),
95103
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
96-
language: $.field($.Output.Nullable(() => Language), $.Args({ code: $Scalar.ID })),
104+
language: $.field($.Output.Nullable(() => Language), $.Args({ code: $.Input.Field($Scalar.ID) }, false)),
97105
// @ts-ignore - circular types cannot infer. Ignore in case there are any. This comment is always added, it does not indicate if this particular type could infer or not.
98-
languages: $.field($.Output.List(() => Language), $.Args({ filter: $.Input.Nullable(LanguageFilterInput) })),
106+
languages: $.field(
107+
$.Output.List(() => Language),
108+
$.Args({ filter: $.Input.Field($.Input.Nullable(LanguageFilterInput)) }, true),
109+
),
99110
})
100111

101-
export const $Index = {
102-
name: 'Atlas' as const,
112+
export const $Index: Index = {
113+
name: Data.Name,
103114
RootTypesPresent: ['Query'] as const,
115+
RootUnion: undefined as any, // Type level only.
104116
Root: {
105117
Query,
106118
Mutation: null,

examples/$/generated-clients/atlas/modules/Select.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import type { ResultSet, SelectionSet } from '../../../../../src/entrypoints/schema.js'
2+
import * as Data from './Data.js'
23
import type { Index } from './SchemaIndex.js'
34

45
// Runtime
56
// -------
67

78
import { createSelect } from '../../../../../src/entrypoints/client.js'
8-
export const Select = createSelect(`default`)
9+
export const Select = createSelect(Data.Name)
910

1011
// Buildtime
1112
// ---------
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const Name = `Pokemon`
2+
3+
export type Name = 'Pokemon'

examples/$/generated-clients/pokemon/modules/Global.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import type * as Data from './Data.js'
2+
13
import type { Index } from './SchemaIndex.js'
24

35
declare global {
46
export namespace GraffleGlobalTypes {
57
export interface Schemas {
68
Pokemon: {
7-
name: 'Pokemon'
9+
name: Data.Name
810
index: Index
911
customScalars: {}
1012
featureOptions: {

examples/$/generated-clients/pokemon/modules/SchemaBuildtime.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ import type * as $Scalar from './Scalar.ts'
66
// ------------------------------------------------------------ //
77

88
export namespace Root {
9-
export type Mutation = $.Object$2<'Mutation', {
9+
export type Mutation = $.Output.ObjectMutation<{
1010
addPokemon: $.Field<
1111
$.Output.Nullable<Object.Pokemon>,
1212
$.Args<{
13-
attack: $Scalar.Int
14-
defense: $Scalar.Int
15-
hp: $Scalar.Int
16-
name: $Scalar.String
17-
}>
13+
attack: $.Input.Field<$Scalar.Int>
14+
defense: $.Input.Field<$Scalar.Int>
15+
hp: $.Input.Field<$Scalar.Int>
16+
name: $.Input.Field<$Scalar.String>
17+
}, false>
1818
>
1919
}>
2020

21-
export type Query = $.Object$2<'Query', {
21+
export type Query = $.Output.ObjectQuery<{
2222
pokemon: $.Field<$.Output.Nullable<$.Output.List<Object.Pokemon>>, null>
2323
pokemonByName: $.Field<
2424
$.Output.Nullable<$.Output.List<Object.Pokemon>>,
2525
$.Args<{
26-
name: $Scalar.String
27-
}>
26+
name: $.Input.Field<$Scalar.String>
27+
}, false>
2828
>
2929
trainerByName: $.Field<
3030
$.Output.Nullable<Object.Trainer>,
3131
$.Args<{
32-
name: $Scalar.String
33-
}>
32+
name: $.Input.Field<$Scalar.String>
33+
}, false>
3434
>
3535
trainers: $.Field<$.Output.Nullable<$.Output.List<Object.Trainer>>, null>
3636
}>

examples/$/generated-clients/pokemon/modules/SchemaIndex.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
/* eslint-disable */
22

3+
import type * as Data from './Data.js'
4+
35
import type * as Schema from './SchemaBuildtime.js'
46

57
export interface Index {
6-
name: 'Pokemon'
8+
name: Data.Name
79
RootTypesPresent: ['Query', 'Mutation']
10+
RootUnion: Schema.Root.Query | Schema.Root.Mutation
811
Root: {
912
Query: Schema.Root.Query
1013
Mutation: Schema.Root.Mutation

0 commit comments

Comments
 (0)