Skip to content

Commit

Permalink
feat(gql): encode custom scalars (#1178)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt authored Oct 13, 2024
1 parent b597ba0 commit 61b6f50
Show file tree
Hide file tree
Showing 179 changed files with 9,660 additions and 4,587 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ const graffle = Graffle
searchParams: (graphqlRequest) => {
return {
query: graphqlRequest.query,
operationName: `queryContinents`,
operationName: `getPokemon`,
}
},
},
})
})

const result = await graffle.gql`
query trainers {
pokemon { name }
}
query pokemon {
query getTrainers {
trainers { name }
}
query getPokemon {
pokemon { name }
}
`
.send(`queryCountries`)
.send(`getTrainers`)

show(result)
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': '1728323381286'
'x-sent-at-time': '1728856241218'
},
signal: undefined,
method: 'post',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
searchParams: URLSearchParams {},
hash: ''
},
body: '{"query":"mutation { addPokemon(attack:0, defense:0, hp:1, name:\\"Nano\\", type: grass) { name } }"}'
body: '{"query":"mutation {\\n addPokemon(attack: 0, defense: 0, hp: 1, name: \\"Nano\\", type: grass) {\\n name\\n }\\n}"}'
}
---------------------------------------- SHOW ----------------------------------------
{
Expand All @@ -34,7 +34,7 @@
signal: undefined,
method: 'get',
url: URL {
href: 'http://localhost:3000/graphql?query=query+%7B+pokemonByName%28name%3A+%22Nano%22%29+%7B+hp+%7D+%7D',
href: 'http://localhost:3000/graphql?query=%7B%0A++pokemonByName%28name%3A+%22Nano%22%29+%7B%0A++++hp%0A++%7D%0A%7D',
origin: 'http://localhost:3000',
protocol: 'http:',
username: '',
Expand All @@ -43,8 +43,8 @@
hostname: 'localhost',
port: '3000',
pathname: '/graphql',
search: '?query=query+%7B+pokemonByName%28name%3A+%22Nano%22%29+%7B+hp+%7D+%7D',
searchParams: URLSearchParams { 'query' => 'query { pokemonByName(name: "Nano") { hp } }' },
search: '?query=%7B%0A++pokemonByName%28name%3A+%22Nano%22%29+%7B%0A++++hp%0A++%7D%0A%7D',
searchParams: URLSearchParams { 'query' => '{\n pokemonByName(name: "Nano") {\n hp\n }\n}' },
hash: ''
}
}
2 changes: 1 addition & 1 deletion examples/__outputs__/20_output/output_envelope.output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
headers: Headers {
'content-type': 'application/graphql-response+json; charset=utf-8',
'content-length': '142',
date: 'Mon, 07 Oct 2024 17:49:41 GMT',
date: 'Sun, 13 Oct 2024 21:50:41 GMT',
connection: 'keep-alive',
'keep-alive': 'timeout=5'
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
at runPipeline (/some/path/to/runPipeline.ts:XX:XX:18)
at async Object.run (/some/path/to/main.ts:XX:XX:22)
at async executeDocument (/some/path/to/requestMethods.ts:XX:XX:18)
at async executeRootTypeField (/some/path/to/requestMethods.ts:XX:XX:18)
at async executeRootField (/some/path/to/requestMethods.ts:XX:XX:18)
at async <anonymous> (/some/path/to/output_envelope_envelope-error__envelope-error.ts:XX:XX:16) {
context: {
hookName: 'encode',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ContextualError: There was an error in the extension "anonymous" (use named func
at runPipeline (/some/path/to/runPipeline.ts:XX:XX:18)
at async Object.run (/some/path/to/main.ts:XX:XX:22)
at async executeDocument (/some/path/to/requestMethods.ts:XX:XX:18)
at async executeRootTypeField (/some/path/to/requestMethods.ts:XX:XX:18)
at async executeRootField (/some/path/to/requestMethods.ts:XX:XX:18)
at async <anonymous> (/some/path/to/output_envelope_envelope_error-throw__envelope-error-throw.ts:XX:XX:1) {
context: {
hookName: 'encode',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ ContextualError: There was an error in the core implementation of hook "exchange
[cause]: TypeError: Failed to parse URL from ...
at new Request (node:internal/deps/undici/undici:XX:XX)
at Object.run (/some/path/to/core.ts:XX:XX:29)
... 3 lines matching cause stack trace ...
at async applyBody (/some/path/to/main.ts:XX:XX:22) {
at runHook (/some/path/to/runHook.ts:XX:XX:37)
at runHook (/some/path/to/runHook.ts:XX:XX:16) {
[cause]: TypeError: Invalid URL
at new URL (node:internal/url:XX:XX)
at new Request (node:internal/deps/undici/undici:XX:XX)
at Object.run (/some/path/to/core.ts:XX:XX:29)
at runHook (/some/path/to/runHook.ts:XX:XX:37)
at <anonymous> (/some/path/to/runHook.ts:XX:XX:14)
at onRequest (/some/path/to/extension.ts:XX:XX:32)
at async applyBody (/some/path/to/main.ts:XX:XX:22) {
at runHook (/some/path/to/runHook.ts:XX:XX:16) {
code: 'ERR_INVALID_URL',
input: '...'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ContextualError: There was an error in the extension "anonymous" (use named func
at runPipeline (/some/path/to/runPipeline.ts:XX:XX:18)
at async Object.run (/some/path/to/main.ts:XX:XX:22)
at async executeDocument (/some/path/to/requestMethods.ts:XX:XX:18)
at async executeRootTypeField (/some/path/to/requestMethods.ts:XX:XX:18)
at async executeRootField (/some/path/to/requestMethods.ts:XX:XX:18)
at async <anonymous> (/some/path/to/output_return-error.ts:XX:XX:18) {
context: {
hookName: 'encode',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ContextualAggregateError: One or more errors in the execution result.
at handleOutput (/some/path/to/handleOutput.ts:XX:XX:19)
at executeDocument (/some/path/to/requestMethods.ts:XX:XX:10)
at process.processTicksAndRejections (node:internal/process/task_queues:XX:XX)
at async executeRootTypeField (/some/path/to/requestMethods.ts:XX:XX:18)
at async executeRootField (/some/path/to/requestMethods.ts:XX:XX:18)
at async <anonymous> (/some/path/to/output_return-error_return-error-execution__return-error-execution.ts:XX:XX:16) {
context: {},
cause: undefined,
Expand Down Expand Up @@ -39,7 +39,7 @@ ContextualError: There was an error in the extension "anonymous" (use named func
at process.processTicksAndRejections (node:internal/process/task_queues:XX:XX)
at async Object.run (/some/path/to/main.ts:XX:XX:22)
at async executeDocument (/some/path/to/requestMethods.ts:XX:XX:18)
at async executeRootTypeField (/some/path/to/requestMethods.ts:XX:XX:18)
at async executeRootField (/some/path/to/requestMethods.ts:XX:XX:18)
at async <anonymous> (/some/path/to/output_return-error_return-error-execution__return-error-execution.ts:XX:XX:3) {
context: {
hookName: 'encode',
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
/some/path/to/runPipeline.ts:XX:XX
return new ContextualError(message, { hookName: signal.hookName, source: signal.source }, signal.error)
^


ContextualError: There was an error in the core implementation of hook "pack".
at runPipeline (/some/path/to/runPipeline.ts:XX:XX:18)
at async runPipeline (/some/path/to/runPipeline.ts:XX:XX:14)
at async Object.run (/some/path/to/main.ts:XX:XX:22)
at async Object.send (/some/path/to/gql.ts:XX:XX:26)
at async <anonymous> (/some/path/to/anyware_slot_slot-body__slot-search-params.ts:XX:XX:16) {
context: { hookName: 'pack', source: 'implementation' },
cause: Error: Unexpected null value.
at throwNull (/some/path/to/prelude.ts:XX:XX:29)
at Object.run (/some/path/to/core.ts:XX:XX:35)
at runHook (/some/path/to/runHook.ts:XX:XX:37)
at <anonymous> (/some/path/to/runHook.ts:XX:XX:14)
at <anonymous> (/some/path/to/anyware_slot_slot-body__slot-search-params.ts:XX:XX:18)
at applyBody (/some/path/to/main.ts:XX:XX:28)
}

Node.js vXX.XX.XX
---------------------------------------- SHOW ----------------------------------------
{
pokemon: [
{ name: 'Pikachu' },
{ name: 'Charizard' },
{ name: 'Squirtle' },
{ name: 'Bulbasaur' },
{ name: 'Caterpie' },
{ name: 'Weedle' }
]
}
Loading

0 comments on commit 61b6f50

Please sign in to comment.