Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2d1888

Browse files
authored
fix(ts-client): select (#816)
1 parentfb715d9 commite2d1888

File tree

9 files changed

+209
-193
lines changed

9 files changed

+209
-193
lines changed

‎src/layers/2_generator/__snapshots__/files.test.ts.snap

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exports[`schema2 2`] = `
1717
exports[`schema2 3`]=`
1818
"export{create} from './Client.js'
1919
export{isError} from './Error.js'
20-
export* asSelect from './Select.js'
20+
export{Select} from './Select.js'
2121
"
2222
`;
2323

@@ -52,106 +52,106 @@ import { Index } from './Index.js'
5252
import{createSelect} from '../../../../src/entrypoints/alpha/client.js'
5353
export const Select = createSelect('default')
5454
55-
//Root Types
56-
// ----------
55+
//Buildtime
56+
// ---------
5757
58-
export type Mutation<$SelectionSetextendsSelectionSet.Root<Index,'Mutation'>> = ResultSet.Root<
59-
$SelectionSet,
60-
Index,
61-
'Mutation'
62-
>
58+
export namespace Select{
59+
// Root Types
60+
// ----------
6361
64-
export typeQuery<$SelectionSetextendsSelectionSet.Root<Index,'Query'>> = ResultSet.Root<
65-
$SelectionSet,
66-
Index,
67-
'Query'
68-
>
62+
exporttypeMutation<$SelectionSetextendsSelectionSet.Root<Index,'Mutation'>>=ResultSet.Root<
63+
$SelectionSet,
64+
Index,
65+
'Mutation'
66+
>
6967
70-
// Object Types
71-
// ------------
68+
exporttypeQuery<$SelectionSetextendsSelectionSet.Root<Index,'Query'>>=ResultSet.Root<
69+
$SelectionSet,
70+
Index,
71+
'Query'
72+
>
7273
73-
export type Bar<$SelectionSetextendsSelectionSet.Object<Index['objects']['Bar'],Index>> = ResultSet.Object$<
74-
$SelectionSet,
75-
Index['objects']['Bar'],
76-
Index
77-
>
74+
// Object Types
75+
// ------------
7876
79-
export type DateObject1<$SelectionSetextendsSelectionSet.Object<Index['objects']['DateObject1'],Index>> =
80-
ResultSet.Object$<$SelectionSet, Index['objects']['DateObject1'], Index>
77+
exporttypeBar<$SelectionSetextendsSelectionSet.Object<Index['objects']['Bar'],Index>>=ResultSet.Object$<
78+
$SelectionSet,
79+
Index['objects']['Bar'],
80+
Index
81+
>
8182
82-
export typeDateObject2<$SelectionSetextendsSelectionSet.Object<Index['objects']['DateObject2'],Index>> =
83-
ResultSet.Object$<$SelectionSet, Index['objects']['DateObject2'], Index>
83+
exporttypeDateObject1<$SelectionSetextendsSelectionSet.Object<Index['objects']['DateObject1'],Index>>=
84+
ResultSet.Object$<$SelectionSet,Index['objects']['DateObject1'],Index>
8485
85-
export typeErrorOne<$SelectionSetextendsSelectionSet.Object<Index['objects']['ErrorOne'],Index>> =
86-
ResultSet.Object$<$SelectionSet, Index['objects']['ErrorOne'], Index>
86+
exporttypeDateObject2<$SelectionSetextendsSelectionSet.Object<Index['objects']['DateObject2'],Index>>=
87+
ResultSet.Object$<$SelectionSet,Index['objects']['DateObject2'],Index>
8788
88-
export typeErrorTwo<$SelectionSetextendsSelectionSet.Object<Index['objects']['ErrorTwo'],Index>> =
89-
ResultSet.Object$<$SelectionSet, Index['objects']['ErrorTwo'], Index>
89+
exporttypeErrorOne<$SelectionSetextendsSelectionSet.Object<Index['objects']['ErrorOne'],Index>>=
90+
ResultSet.Object$<$SelectionSet,Index['objects']['ErrorOne'],Index>
9091
91-
export type Foo<$SelectionSetextendsSelectionSet.Object<Index['objects']['Foo'],Index>> = ResultSet.Object$<
92-
$SelectionSet,
93-
Index['objects']['Foo'],
94-
Index
95-
>
92+
exporttypeErrorTwo<$SelectionSetextendsSelectionSet.Object<Index['objects']['ErrorTwo'],Index>>=
93+
ResultSet.Object$<$SelectionSet,Index['objects']['ErrorTwo'],Index>
9694
97-
export typeObject1<$SelectionSetextendsSelectionSet.Object<Index['objects']['Object1'],Index>> = ResultSet.Object$<
98-
$SelectionSet,
99-
Index['objects']['Object1'],
100-
Index
101-
>
95+
exporttypeFoo<$SelectionSetextendsSelectionSet.Object<Index['objects']['Foo'],Index>>=ResultSet.Object$<
96+
$SelectionSet,
97+
Index['objects']['Foo'],
98+
Index
99+
>
102100
103-
export type Object1ImplementingInterface<
104-
$SelectionSet extends SelectionSet.Object<Index['objects']['Object1ImplementingInterface'], Index>,
105-
> = ResultSet.Object$<$SelectionSet, Index['objects']['Object1ImplementingInterface'], Index>
101+
exporttypeObject1<$SelectionSetextendsSelectionSet.Object<Index['objects']['Object1'],Index>>=
102+
ResultSet.Object$<$SelectionSet,Index['objects']['Object1'],Index>
106103
107-
export typeObject2ImplementingInterface<
108-
$SelectionSet extends SelectionSet.Object<Index['objects']['Object2ImplementingInterface'], Index>,
109-
> = ResultSet.Object$<$SelectionSet, Index['objects']['Object2ImplementingInterface'], Index>
104+
exporttypeObject1ImplementingInterface<
105+
$SelectionSetextendsSelectionSet.Object<Index['objects']['Object1ImplementingInterface'],Index>,
106+
>=ResultSet.Object$<$SelectionSet,Index['objects']['Object1ImplementingInterface'],Index>
110107
111-
export type ObjectNested<$SelectionSetextendsSelectionSet.Object<Index['objects']['ObjectNested'],Index>> =
112-
ResultSet.Object$<$SelectionSet, Index['objects']['ObjectNested'], Index>
108+
exporttypeObject2ImplementingInterface<
109+
$SelectionSetextendsSelectionSet.Object<Index['objects']['Object2ImplementingInterface'],Index>,
110+
>=ResultSet.Object$<$SelectionSet,Index['objects']['Object2ImplementingInterface'],Index>
113111
114-
export typeObjectUnion<$SelectionSetextendsSelectionSet.Object<Index['objects']['ObjectUnion'],Index>> =
115-
ResultSet.Object$<$SelectionSet, Index['objects']['ObjectUnion'], Index>
112+
exporttypeObjectNested<$SelectionSetextendsSelectionSet.Object<Index['objects']['ObjectNested'],Index>>=
113+
ResultSet.Object$<$SelectionSet,Index['objects']['ObjectNested'],Index>
116114
117-
export typelowerCaseObject<$SelectionSetextendsSelectionSet.Object<Index['objects']['lowerCaseObject'],Index>> =
118-
ResultSet.Object$<$SelectionSet, Index['objects']['lowerCaseObject'], Index>
115+
exporttypeObjectUnion<$SelectionSetextendsSelectionSet.Object<Index['objects']['ObjectUnion'],Index>>=
116+
ResultSet.Object$<$SelectionSet,Index['objects']['ObjectUnion'],Index>
119117
120-
export typelowerCaseObject2<$SelectionSetextendsSelectionSet.Object<Index['objects']['lowerCaseObject2'],Index>> =
121-
ResultSet.Object$<$SelectionSet, Index['objects']['lowerCaseObject2'], Index>
118+
exporttypelowerCaseObject<$SelectionSetextendsSelectionSet.Object<Index['objects']['lowerCaseObject'],Index>>=
119+
ResultSet.Object$<$SelectionSet,Index['objects']['lowerCaseObject'],Index>
122120
123-
// Union Types
124-
// -----------
121+
exporttypelowerCaseObject2<$SelectionSetextendsSelectionSet.Object<Index['objects']['lowerCaseObject2'],Index>>=
122+
ResultSet.Object$<$SelectionSet,Index['objects']['lowerCaseObject2'],Index>
125123
126-
export type DateUnion<$SelectionSetextendsSelectionSet.Union<Index['unions']['DateUnion'],Index>> = ResultSet.Union<
127-
$SelectionSet,
128-
Index['unions']['DateUnion'],
129-
Index
130-
>
124+
// Union Types
125+
// -----------
131126
132-
export typeFooBarUnion<$SelectionSetextendsSelectionSet.Union<Index['unions']['FooBarUnion'],Index>> =
133-
ResultSet.Union<$SelectionSet, Index['unions']['FooBarUnion'], Index>
127+
exporttypeDateUnion<$SelectionSetextendsSelectionSet.Union<Index['unions']['DateUnion'],Index>>=
128+
ResultSet.Union<$SelectionSet,Index['unions']['DateUnion'],Index>
134129
135-
export type Result<$SelectionSetextendsSelectionSet.Union<Index['unions']['Result'],Index>> = ResultSet.Union<
136-
$SelectionSet,
137-
Index['unions']['Result'],
138-
Index
139-
>
130+
exporttypeFooBarUnion<$SelectionSetextendsSelectionSet.Union<Index['unions']['FooBarUnion'],Index>>=
131+
ResultSet.Union<$SelectionSet,Index['unions']['FooBarUnion'],Index>
140132
141-
export type lowerCaseUnion<$SelectionSetextendsSelectionSet.Union<Index['unions']['lowerCaseUnion'],Index>> =
142-
ResultSet.Union<$SelectionSet, Index['unions']['lowerCaseUnion'], Index>
133+
exporttypeResult<$SelectionSetextendsSelectionSet.Union<Index['unions']['Result'],Index>>=ResultSet.Union<
134+
$SelectionSet,
135+
Index['unions']['Result'],
136+
Index
137+
>
143138
144-
// Interface Types
145-
// ---------------
139+
exporttypelowerCaseUnion<$SelectionSetextendsSelectionSet.Union<Index['unions']['lowerCaseUnion'],Index>>=
140+
ResultSet.Union<$SelectionSet,Index['unions']['lowerCaseUnion'],Index>
146141
147-
export type DateInterface1<$SelectionSetextendsSelectionSet.Interface<Index['interfaces']['DateInterface1'],Index>> =
148-
ResultSet.Interface<$SelectionSet, Index['interfaces']['DateInterface1'], Index>
142+
//Interface Types
143+
// ---------------
149144
150-
export type Error<$SelectionSetextendsSelectionSet.Interface<Index['interfaces']['Error'],Index>> =
151-
ResultSet.Interface<$SelectionSet, Index['interfaces']['Error'], Index>
145+
exporttypeDateInterface1<
146+
$SelectionSetextendsSelectionSet.Interface<Index['interfaces']['DateInterface1'],Index>,
147+
>=ResultSet.Interface<$SelectionSet,Index['interfaces']['DateInterface1'],Index>
152148
153-
export type Interface<$SelectionSetextendsSelectionSet.Interface<Index['interfaces']['Interface'],Index>> =
154-
ResultSet.Interface<$SelectionSet, Index['interfaces']['Interface'], Index>
149+
exporttypeError<$SelectionSetextendsSelectionSet.Interface<Index['interfaces']['Error'],Index>>=
150+
ResultSet.Interface<$SelectionSet,Index['interfaces']['Error'],Index>
151+
152+
exporttypeInterface<$SelectionSetextendsSelectionSet.Interface<Index['interfaces']['Interface'],Index>>=
153+
ResultSet.Interface<$SelectionSet,Index['interfaces']['Interface'],Index>
154+
}
155155
"
156156
`;
157157

‎src/layers/2_generator/code/Select.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ export const { generate: generateSelect, moduleName: moduleNameSelect } = create
1111
code.push(`import { SelectionSet, ResultSet } from '${config.libraryPaths.schema}'`)
1212
code.push(``)
1313

14-
code.push(title(`Runtime`))
15-
code.push(`import { createSelect } from '${config.libraryPaths.client}'`)
16-
code.push(`export const Select = createSelect('default')`)
17-
code.push(``)
18-
19-
code.push(typeTitle(config,`Root`))
14+
code.push(
15+
title(`Runtime`),
16+
`import { createSelect } from '${config.libraryPaths.client}'`,
17+
`export const Select = createSelect('default')`,
18+
``,
19+
title(`Buildtime`),
20+
``,
21+
`export namespace Select {`,
22+
typeTitle(config,`Root`),
23+
)
2024

2125
code.push(...config.typeMapByKind.GraphQLRootType.map((type)=>{
2226
return`export type${type.name}<$SelectionSet extends SelectionSet.Root<Index, '${type.name}'>> = ResultSet.Root<$SelectionSet, Index, '${type.name}'>\n`
@@ -41,6 +45,8 @@ export const { generate: generateSelect, moduleName: moduleNameSelect } = create
4145
return`export type${type.name}<$SelectionSet extends SelectionSet.Interface<Index['interfaces']['${type.name}'], Index>> = ResultSet.Interface<$SelectionSet, Index['interfaces']['${type.name}'], Index>\n`
4246
}))
4347

48+
code.push(`}`)// namespace Select
49+
4450
returncode.join(`\n`)
4551
},
4652
)

‎src/layers/2_generator/code/_.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const { generate: generate_, moduleName: moduleName_ } = createCodeGenera
88
(_config)=>{
99
constcode:string[]=[]
1010
code.push(
11-
`export* asSelect from './${moduleNameSelect}.js'`,
11+
`export{Select } from './${moduleNameSelect}.js'`,
1212
`export { isError } from './${moduleNameError}.js'`,
1313
`export { create } from './${moduleNameClient}.js'`,
1414
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp