Skip to content

Commit 5555c20

Browse files
authored
fix: result-set decode aliases (#1129)
1 parent f1984c4 commit 5555c20

File tree

27 files changed

+332
-228
lines changed

27 files changed

+332
-228
lines changed

examples/$/generated-clients/pokemon/_.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ import './modules/Global.js'
66

77
export { create } from './modules/Client.js'
88
export { isError } from './modules/Error.js'
9+
export { $Index as schemaModel } from './modules/SchemaRuntime.js'
910
export { Select } from './modules/Select.js'
11+
export * as SelectionSets from './modules/SelectionSets.js'

examples/__outputs__/10_transport-http/transport-http_extension_headers__dynamicHeaders.output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
headers: Headers {
55
accept: 'application/graphql-response+json; charset=utf-8, application/json; charset=utf-8',
66
'content-type': 'application/json',
7-
'x-sent-at-time': '1727310087052'
7+
'x-sent-at-time': '1727319638284'
88
},
99
signal: undefined,
1010
method: 'post',

examples/__outputs__/20_output/output_envelope.output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
headers: Headers {
1717
'content-type': 'application/graphql-response+json; charset=utf-8',
1818
'content-length': '104',
19-
date: 'Thu, 26 Sep 2024 00:21:27 GMT',
19+
date: 'Thu, 26 Sep 2024 03:00:38 GMT',
2020
connection: 'keep-alive',
2121
'keep-alive': 'timeout=5'
2222
},

examples/__outputs__/60_extension/extension_opentelemetry__opentelemetry.output.txt

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
}
1010
},
1111
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
12-
traceId: 'f384fda0c6aa8cdc0600586696d83aac',
13-
parentId: '78959de15b116846',
12+
traceId: '851f3f771b76e4969a2f8c084f85759d',
13+
parentId: 'ebd5237ad56b820c',
1414
traceState: undefined,
1515
name: 'encode',
16-
id: 'e78df0ee2a54acb6',
16+
id: 'ff492c55cf5462ff',
1717
kind: 0,
18-
timestamp: 1727310087760000,
19-
duration: 554.291,
18+
timestamp: 1727319638868000,
19+
duration: 1170.584,
2020
attributes: {},
2121
status: { code: 0 },
2222
events: [],
@@ -33,14 +33,14 @@
3333
}
3434
},
3535
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
36-
traceId: 'f384fda0c6aa8cdc0600586696d83aac',
37-
parentId: '78959de15b116846',
36+
traceId: '851f3f771b76e4969a2f8c084f85759d',
37+
parentId: 'ebd5237ad56b820c',
3838
traceState: undefined,
3939
name: 'pack',
40-
id: '88b5c48ab9be7a36',
40+
id: '9174a3424a228e28',
4141
kind: 0,
42-
timestamp: 1727310087845000,
43-
duration: 17482.625,
42+
timestamp: 1727319638871000,
43+
duration: 36417.291,
4444
attributes: {},
4545
status: { code: 0 },
4646
events: [],
@@ -57,14 +57,14 @@
5757
}
5858
},
5959
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
60-
traceId: 'f384fda0c6aa8cdc0600586696d83aac',
61-
parentId: '78959de15b116846',
60+
traceId: '851f3f771b76e4969a2f8c084f85759d',
61+
parentId: 'ebd5237ad56b820c',
6262
traceState: undefined,
6363
name: 'exchange',
64-
id: 'd4a611cb0daf3ac1',
64+
id: '85de30bd471a1d11',
6565
kind: 0,
66-
timestamp: 1727310087867000,
67-
duration: 48095.333,
66+
timestamp: 1727319638909000,
67+
duration: 24460.084,
6868
attributes: {},
6969
status: { code: 0 },
7070
events: [],
@@ -81,14 +81,14 @@
8181
}
8282
},
8383
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
84-
traceId: 'f384fda0c6aa8cdc0600586696d83aac',
85-
parentId: '78959de15b116846',
84+
traceId: '851f3f771b76e4969a2f8c084f85759d',
85+
parentId: 'ebd5237ad56b820c',
8686
traceState: undefined,
8787
name: 'unpack',
88-
id: '20d213f3a3f86f1d',
88+
id: '81208c873ce84df5',
8989
kind: 0,
90-
timestamp: 1727310087916000,
91-
duration: 1125.833,
90+
timestamp: 1727319638933000,
91+
duration: 1301.541,
9292
attributes: {},
9393
status: { code: 0 },
9494
events: [],
@@ -105,14 +105,14 @@
105105
}
106106
},
107107
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
108-
traceId: 'f384fda0c6aa8cdc0600586696d83aac',
109-
parentId: '78959de15b116846',
108+
traceId: '851f3f771b76e4969a2f8c084f85759d',
109+
parentId: 'ebd5237ad56b820c',
110110
traceState: undefined,
111111
name: 'decode',
112-
id: 'c35ae080bfb451be',
112+
id: '0e084f67d12e45c7',
113113
kind: 0,
114-
timestamp: 1727310087917000,
115-
duration: 181.958,
114+
timestamp: 1727319638935000,
115+
duration: 199.208,
116116
attributes: {},
117117
status: { code: 0 },
118118
events: [],
@@ -129,14 +129,14 @@
129129
}
130130
},
131131
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
132-
traceId: 'f384fda0c6aa8cdc0600586696d83aac',
132+
traceId: '851f3f771b76e4969a2f8c084f85759d',
133133
parentId: undefined,
134134
traceState: undefined,
135135
name: 'request',
136-
id: '78959de15b116846',
136+
id: 'ebd5237ad56b820c',
137137
kind: 0,
138-
timestamp: 1727310087759000,
139-
duration: 158234.5,
138+
timestamp: 1727319638867000,
139+
duration: 68430.791,
140140
attributes: {},
141141
status: { code: 0 },
142142
events: [],

src/layers/2_SelectionSet/indicator.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const indicator = {
3737
...positiveIndicator,
3838
}
3939

40+
export type Any = ClientIndicator | (Directive.$Fields & { $?: Schema.Args<any> })
41+
4042
/**
4143
* Field selection in general, with directives support too.
4244
* If a field directive is given as an indicator then it implies "select this" e.g. `true`/`1`.
@@ -46,9 +48,11 @@ export type NoArgsIndicator = ClientIndicator | Directive.$Fields
4648

4749
export type NoArgsIndicator$Expanded = UnionExpanded<ClientIndicator | Simplify<Directive.$Fields>>
4850

49-
export type ArgsIndicator<$Args extends Schema.Args<any>> = $Args['isFieldsAllNullable'] extends true
50-
? ({ $?: Args<$Args> } & Directive.$Fields) | ClientIndicator
51-
: { $: Args<$Args> } & Directive.$Fields
51+
// dprint-ignore
52+
export type ArgsIndicator<$Args extends Schema.Args<any>> =
53+
$Args['isFieldsAllNullable'] extends true
54+
? ({ $?: Args<$Args> } & Directive.$Fields) | ClientIndicator
55+
: { $: Args<$Args> } & Directive.$Fields
5256

5357
// dprint-ignore
5458
export type IndicatorForField<$Field extends SomeField> =

src/layers/2_SelectionSet/on.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { OmitKeysWithPrefix } from '../../lib/prelude.js'
2-
import type { Any } from './types.js'
32

43
export const prefix = `___on_`
54

@@ -28,4 +27,8 @@ export const toGraphQLOn = (on: On) => {
2827
return `...on ${on.typeOrFragmentName}`
2928
}
3029

31-
export type OmitOnTypeFragments<$Object extends Any> = OmitKeysWithPrefix<$Object, KeyPrefix>
30+
export type OmitOnTypeFragments<$Object> = OmitKeysWithPrefix<
31+
// @ts-expect-error fixme
32+
$Object,
33+
KeyPrefix
34+
>

src/layers/2_SelectionSet/print.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export type DocumentObject = {
2929

3030
export type GraphQLRootSelection = { query: GraphQLObjectSelection } | { mutation: GraphQLObjectSelection }
3131

32+
// todo duplicaets the ObjectLike type in other module
3233
export type GraphQLObjectSelection = Record<string, Indicator | SS>
3334

3435
export type SS = {

src/layers/2_SelectionSet/types.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import type { OmitNullableFields, PickNullableFields, Schema } from '../1_Schema
33
import type { Indicator } from './_indicator.js'
44
import type { Directive } from './Directive/__.js'
55

6-
export type Any = object
6+
export type ObjectLike = {
7+
[fieldName: string]: Any
8+
}
9+
10+
export type Any = AnyExceptAlias | AliasInput
11+
12+
export type AnyExceptAlias = ObjectLike | Indicator.Any
713

814
export type IsSelectScalarsWildcard<SS> = SS extends { $scalars: Indicator.ClientIndicatorPositive } ? true : false
915

@@ -62,15 +68,17 @@ export namespace Bases {
6268

6369
// dprint-ignore
6470

65-
export type AliasInputOne<$SelectionSet = unknown> = [alias: string, selectionSet: $SelectionSet]
71+
export type AliasInputOne<$SelectionSet = AnyExceptAlias> = [alias: string, selectionSet: $SelectionSet]
6672

67-
export type AliasInputMultiple<$SelectionSet = unknown> = [
73+
export type AliasInputMultiple<$SelectionSet = AnyExceptAlias> = [
6874
...AliasInputOne<$SelectionSet>[],
6975
]
7076

71-
export type AliasInput<$SelectionSet = unknown> = AliasInputOne<$SelectionSet> | AliasInputMultiple<$SelectionSet>
77+
export type AliasInput<$SelectionSet = AnyExceptAlias> =
78+
| AliasInputOne<$SelectionSet>
79+
| AliasInputMultiple<$SelectionSet>
7280

73-
export type AliasNormalized<$SelectionSet = unknown> = [
81+
export type AliasNormalized<$SelectionSet = AnyExceptAlias> = [
7482
alias: string,
7583
selectionSet: $SelectionSet,
7684
][]

src/layers/3_ResultSet/__.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * as ResultSet from './types.js'
1+
export * as ResultSet from './infer.js'

src/layers/3_ResultSet/customScalars.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)