Skip to content

Commit

Permalink
fix: raw variables inference (#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt authored Sep 10, 2024
1 parent 6bbe63f commit 16377bb
Show file tree
Hide file tree
Showing 52 changed files with 581 additions and 272 deletions.
27 changes: 27 additions & 0 deletions examples/output|output_envelope.output.test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---------------------------------------- SHOW ----------------------------------------
{
data: {
continents: [
{ name: 'Africa' },
{ name: 'Antarctica' },
{ name: 'Asia' },
{ name: 'Europe' },
{ name: 'North America' },
{ name: 'Oceania' },
{ name: 'South America' }
]
},
errors: undefined,
extensions: undefined,
response: Response {
status: 200,
statusText: '',
headers: DYNAMIC_VALUE,
body: ReadableStream { locked: true, state: 'closed', supportsBYOB: true },
bodyUsed: true,
ok: true,
redirected: false,
type: 'basic',
url: 'https://countries.trevorblades.com/graphql'
}
}
10 changes: 5 additions & 5 deletions examples/output|output_envelope.output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
headers: Headers {
connection: 'keep-alive',
'content-length': '119',
'x-served-by': 'cache-yul1970029-YUL',
'x-served-by': 'cache-yul1970051-YUL',
'accept-ranges': 'bytes',
date: 'Sun, 08 Sep 2024 18:13:26 GMT',
'content-type': 'application/graphql-response+json; charset=utf-8',
Expand All @@ -32,13 +32,13 @@
'alt-svc': 'h3=":443"; ma=86400',
'access-control-allow-origin': '*',
'x-powered-by': 'Stellate',
age: '110231',
age: '158583',
'cache-control': 'public, s-maxage=2628000, stale-while-revalidate=2628000',
'x-cache': 'HIT',
'x-cache-hits': '3',
'x-cache-hits': '36',
'gcdn-cache': 'HIT',
'stellate-rate-limit-budget-remaining': '49',
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=49;refill=60',
'stellate-rate-limit-budget-remaining': '44',
'stellate-rate-limit-rules': '"IP limit";type="RequestCount";budget=50;limited=?0;remaining=44;refill=60',
'stellate-rate-limit-decision': 'pass',
'stellate-rate-limit-budget-required': '5',
'content-encoding': 'br'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---------------------------------------- SHOW ----------------------------------------
{
errors: [
ContextualError: There was an error in the extension "anonymous" (use named functions to improve this error message) while running hook "encode".
at runPipeline (/some/path/to/runPipeline.ts:76:18)
at async Object.run (/some/path/to/main.ts:286:22)
at async run (/some/path/to/client.ts:256:20)
at async executeRootType (/some/path/to/client.ts:185:12)
at async executeRootTypeField (/some/path/to/client.ts:216:20)
at async <anonymous> (/some/path/to/output|output_envelope_envelope-error__envelope-error.ts:24:16) {
context: {
hookName: 'encode',
source: 'extension',
extensionName: 'anonymous'
},
cause: Error: Something went wrong.
at <anonymous> (/some/path/to/output|output_envelope_envelope-error__envelope-error.ts:20:9)
at applyBody (/some/path/to/main.ts:310:28)
}
]
}
26 changes: 26 additions & 0 deletions examples/output|output_envelope_envelope-error__envelope-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* This example shows how to configure output to embed errors into the envelope.
*/

import { Atlas } from './$/generated-clients/atlas/__.js'
import { show } from './$/helpers.js'

// dprint-ignore
const atlas = Atlas.create({
output: {
envelope: {
errors: {
// ^^^^^^
execution: true, // default
other: true,
},
},
},
}).use(({ encode: _ }) => {
throw new Error(`Something went wrong.`)
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
})

const result = await atlas.query.continents({ name: true })

show(result)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/some/path/to/runPipeline.ts:76
return new ContextualError(message, {
^


ContextualError: There was an error in the extension "anonymous" (use named functions to improve this error message) while running hook "encode".
at runPipeline (/some/path/to/runPipeline.ts:76:18)
at async Object.run (/some/path/to/main.ts:286:22)
at async run (/some/path/to/client.ts:256:20)
at async executeRootType (/some/path/to/client.ts:185:12)
at async executeRootTypeField (/some/path/to/client.ts:216:20)
at async <anonymous> (/some/path/to/output|output_envelope_envelope_error-throw__envelope-error-throw.ts:22:1) {
context: {
hookName: 'encode',
source: 'extension',
extensionName: 'anonymous'
},
cause: Error: Something went wrong.
at <anonymous> (/some/path/to/output|output_envelope_envelope_error-throw__envelope-error-throw.ts:18:9)
at applyBody (/some/path/to/main.ts:310:28)
}

Node.js vXX.XX.XX
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* This example shows how to configure output to throw errors even when using the envelope.
*/

import { Atlas } from './$/generated-clients/atlas/__.js'

// dprint-ignore
const atlas = Atlas.create({
output: {
envelope: {
errors: {
execution: false,
other: false, // default
}
},
},
}).use(({ encode: _ }) => {
throw new Error(`Something went wrong.`)
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
})

await atlas.query.continents({ name: true })
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---------------------------------------- SHOW ----------------------------------------
{
methodMode: 'post',
headers: Headers {
accept: 'application/graphql-response+json; charset=utf-8, application/json; charset=utf-8',
'content-type': 'application/json',
'x-sent-at-time': 'DYNAMIC_VALUE'
},
signal: undefined,
method: 'post',
url: 'https://countries.trevorblades.com/graphql',
body: '{"query":"{ languages { code } }"}'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
headers: Headers {
accept: 'application/graphql-response+json; charset=utf-8, application/json; charset=utf-8',
'content-type': 'application/json',
'x-sent-at-time': '1725929436225'
'x-sent-at-time': '1725977788513'
},
signal: undefined,
method: 'post',
Expand Down
Loading

0 comments on commit 16377bb

Please sign in to comment.