-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ts-client): custom scalar runtime codecs (#746)
- Loading branch information
1 parent
be14f81
commit 5658370
Showing
39 changed files
with
2,078 additions
and
578 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
|
||
import type { Object, Union } from './__.js' | ||
import type { Object$2, Union } from './__.js' | ||
|
||
export interface Index { | ||
Root: { | ||
Query: null | Object | ||
Mutation: null | Object | ||
Subscription: null | Object | ||
} | ||
objects: Record<string, Object> | ||
unions: { | ||
Union: null | Union | ||
Query: null | Object$2 | ||
Mutation: null | Object$2 | ||
Subscription: null | Object$2 | ||
} | ||
objects: Record<string, Object$2> | ||
unions: Record<string, Union> | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,40 @@ | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
|
||
import type { Field } from '../Field/Field.js' | ||
import { field } from '../Field/Field.js' | ||
import { Output } from '../Field/Type.js' | ||
import type { Scalar } from './_.js' | ||
import type { Enum } from './Enum.js' | ||
|
||
export type Fields = Record<string, Field<any>> | ||
export type Fields = Record< | ||
string, | ||
Output.Field<Output.List<any> | Output.Nullable<any> | Object$2 | Enum | Scalar.Any> | ||
> | ||
|
||
export type ObjectFields = { | ||
__typename: Field<Output.__typename> | ||
__typename: Output.Field<Output.__typename> | ||
} & Fields | ||
|
||
export interface Object< | ||
export interface Object$2< | ||
$Name extends string = string, | ||
$Fields extends Fields = Fields, | ||
> { | ||
kind: 'Object' | ||
fields: { | ||
__typename: Field<Output.__typename<$Name>> | ||
__typename: Output.Field<Output.__typename<$Name>> | ||
} & $Fields | ||
} | ||
|
||
export const Object = <$Name extends string, $Fields extends Record<keyof $Fields, Field>>( | ||
// Naming this "Object" breaks Vitest: https://github.com/vitest-dev/vitest/issues/5463 | ||
export const Object$ = <$Name extends string, $Fields extends Record<keyof $Fields, Output.Field>>( | ||
name: $Name, | ||
fields: $Fields, | ||
): Object<$Name, $Fields> => ({ | ||
// eslint-disable-next-line | ||
// @ts-ignore infinite depth issue | ||
): Object$2<$Name, $Fields> => ({ | ||
kind: `Object`, | ||
fields: { | ||
__typename: field(Output.__typename(name)), | ||
__typename: Output.field(Output.__typename(name)), | ||
...fields, | ||
}, | ||
}) | ||
|
||
export { Object$ as Object } |
Oops, something went wrong.