Skip to content

Commit 16377bb

Browse files
authored
fix: raw variables inference (#1077)
1 parent 6bbe63f commit 16377bb

File tree

52 files changed

+581
-272
lines changed

Some content is hidden

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

52 files changed

+581
-272
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---------------------------------------- SHOW ----------------------------------------
2+
{
3+
data: {
4+
continents: [
5+
{ name: 'Africa' },
6+
{ name: 'Antarctica' },
7+
{ name: 'Asia' },
8+
{ name: 'Europe' },
9+
{ name: 'North America' },
10+
{ name: 'Oceania' },
11+
{ name: 'South America' }
12+
]
13+
},
14+
errors: undefined,
15+
extensions: undefined,
16+
response: Response {
17+
status: 200,
18+
statusText: '',
19+
headers: DYNAMIC_VALUE,
20+
body: ReadableStream { locked: true, state: 'closed', supportsBYOB: true },
21+
bodyUsed: true,
22+
ok: true,
23+
redirected: false,
24+
type: 'basic',
25+
url: 'https://countries.trevorblades.com/graphql'
26+
}
27+
}

examples/output|output_envelope.output.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
headers: Headers {
2020
connection: 'keep-alive',
2121
'content-length': '119',
22-
'x-served-by': 'cache-yul1970029-YUL',
22+
'x-served-by': 'cache-yul1970051-YUL',
2323
'accept-ranges': 'bytes',
2424
date: 'Sun, 08 Sep 2024 18:13:26 GMT',
2525
'content-type': 'application/graphql-response+json; charset=utf-8',
@@ -32,13 +32,13 @@
3232
'alt-svc': 'h3=":443"; ma=86400',
3333
'access-control-allow-origin': '*',
3434
'x-powered-by': 'Stellate',
35-
age: '110231',
35+
age: '158583',
3636
'cache-control': 'public, s-maxage=2628000, stale-while-revalidate=2628000',
3737
'x-cache': 'HIT',
38-
'x-cache-hits': '3',
38+
'x-cache-hits': '36',
3939
'gcdn-cache': 'HIT',
40-
'stellate-rate-limit-budget-remaining': '49',
41-
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=49;refill=60',
40+
'stellate-rate-limit-budget-remaining': '44',
41+
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=44;refill=60',
4242
'stellate-rate-limit-decision': 'pass',
4343
'stellate-rate-limit-budget-required': '5',
4444
'content-encoding': 'br'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---------------------------------------- SHOW ----------------------------------------
2+
{
3+
errors: [
4+
ContextualError: There was an error in the extension "anonymous" (use named functions to improve this error message) while running hook "encode".
5+
at runPipeline (/some/path/to/runPipeline.ts:76:18)
6+
at async Object.run (/some/path/to/main.ts:286:22)
7+
at async run (/some/path/to/client.ts:256:20)
8+
at async executeRootType (/some/path/to/client.ts:185:12)
9+
at async executeRootTypeField (/some/path/to/client.ts:216:20)
10+
at async <anonymous> (/some/path/to/output|output_envelope_envelope-error__envelope-error.ts:24:16) {
11+
context: {
12+
hookName: 'encode',
13+
source: 'extension',
14+
extensionName: 'anonymous'
15+
},
16+
cause: Error: Something went wrong.
17+
at <anonymous> (/some/path/to/output|output_envelope_envelope-error__envelope-error.ts:20:9)
18+
at applyBody (/some/path/to/main.ts:310:28)
19+
}
20+
]
21+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* This example shows how to configure output to embed errors into the envelope.
3+
*/
4+
5+
import { Atlas } from './$/generated-clients/atlas/__.js'
6+
import { show } from './$/helpers.js'
7+
8+
// dprint-ignore
9+
const atlas = Atlas.create({
10+
output: {
11+
envelope: {
12+
errors: {
13+
// ^^^^^^
14+
execution: true, // default
15+
other: true,
16+
},
17+
},
18+
},
19+
}).use(({ encode: _ }) => {
20+
throw new Error(`Something went wrong.`)
21+
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22+
})
23+
24+
const result = await atlas.query.continents({ name: true })
25+
26+
show(result)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/some/path/to/runPipeline.ts:76
2+
return new ContextualError(message, {
3+
^
4+
5+
6+
ContextualError: There was an error in the extension "anonymous" (use named functions to improve this error message) while running hook "encode".
7+
at runPipeline (/some/path/to/runPipeline.ts:76:18)
8+
at async Object.run (/some/path/to/main.ts:286:22)
9+
at async run (/some/path/to/client.ts:256:20)
10+
at async executeRootType (/some/path/to/client.ts:185:12)
11+
at async executeRootTypeField (/some/path/to/client.ts:216:20)
12+
at async <anonymous> (/some/path/to/output|output_envelope_envelope_error-throw__envelope-error-throw.ts:22:1) {
13+
context: {
14+
hookName: 'encode',
15+
source: 'extension',
16+
extensionName: 'anonymous'
17+
},
18+
cause: Error: Something went wrong.
19+
at <anonymous> (/some/path/to/output|output_envelope_envelope_error-throw__envelope-error-throw.ts:18:9)
20+
at applyBody (/some/path/to/main.ts:310:28)
21+
}
22+
23+
Node.js vXX.XX.XX
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* This example shows how to configure output to throw errors even when using the envelope.
3+
*/
4+
5+
import { Atlas } from './$/generated-clients/atlas/__.js'
6+
7+
// dprint-ignore
8+
const atlas = Atlas.create({
9+
output: {
10+
envelope: {
11+
errors: {
12+
execution: false,
13+
other: false, // default
14+
}
15+
},
16+
},
17+
}).use(({ encode: _ }) => {
18+
throw new Error(`Something went wrong.`)
19+
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
})
21+
22+
await atlas.query.continents({ name: true })
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---------------------------------------- SHOW ----------------------------------------
2+
{
3+
methodMode: 'post',
4+
headers: Headers {
5+
accept: 'application/graphql-response+json; charset=utf-8, application/json; charset=utf-8',
6+
'content-type': 'application/json',
7+
'x-sent-at-time': 'DYNAMIC_VALUE'
8+
},
9+
signal: undefined,
10+
method: 'post',
11+
url: 'https://countries.trevorblades.com/graphql',
12+
body: '{"query":"{ languages { code } }"}'
13+
}

examples/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': '1725929436225'
7+
'x-sent-at-time': '1725977788513'
88
},
99
signal: undefined,
1010
method: 'post',

0 commit comments

Comments
 (0)