-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(custom-scalars): decode arrays (#1210)
- Loading branch information
1 parent
0a80885
commit 1eb0129
Showing
40 changed files
with
561 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* This example shows how to add a client-side custom scalar codec to | ||
* have arguments and data automatically encoded and decoded respectively. | ||
*/ | ||
|
||
import { Graffle } from '../../src/entrypoints/__Graffle.js' | ||
import { Pokemon } from '../../tests/_/schemas/pokemon/graffle/__.js' | ||
import { show } from '../$/helpers.js' | ||
|
||
const graffle = Pokemon | ||
.create() | ||
.scalar(Graffle.Scalars.create(`Date`, { | ||
encode: (value: globalThis.Date) => value.toISOString(), | ||
decode: (value: string) => { | ||
return new globalThis.Date(value) | ||
}, | ||
})) | ||
|
||
const pokemons = await graffle.query.pokemons({ | ||
$: { filter: { birthday: { lte: new Date(`1987-01-13`) } } }, | ||
name: true, | ||
birthday: true, | ||
}) | ||
|
||
show(`pokemons[0].birthday instanceof Date = ${String(pokemons?.[0]?.birthday instanceof Date)}`) | ||
show(pokemons) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/__outputs__/35_custom-scalar/custom-scalar.output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
---------------------------------------- SHOW ---------------------------------------- | ||
pokemons[0].birthday instanceof Date = true | ||
---------------------------------------- SHOW ---------------------------------------- | ||
[ | ||
{ name: 'Pikachu', birthday: 1850-01-01T00:00:00.000Z }, | ||
{ name: 'Squirtle', birthday: 1910-01-01T00:00:00.000Z } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.