-
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.
refactor(ts-client): schema module (#770)
- Loading branch information
1 parent
33a0278
commit 1287eda
Showing
55 changed files
with
694 additions
and
656 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 @@ | ||
import type { Input } from './_.js' | ||
import type { Nullable } from './Input/types/Nullable.js' | ||
|
||
type InputFields = Record<string, any> | ||
|
||
// dprint-ignore | ||
export type InputFieldsAllNullable<$Fields extends InputFields> = | ||
Exclude<$Fields[keyof $Fields], Nullable<any>> extends never ? true : false | ||
|
||
export interface Args<$Fields extends InputFields> { | ||
fields: $Fields | ||
} | ||
|
||
export const Args = <F extends InputFields>(fields: F): Args<F> => { | ||
return { | ||
fields, | ||
} | ||
} | ||
|
||
export type OmitNullableFields<$Fields extends InputFields> = { | ||
[Key in keyof $Fields as $Fields[Key] extends Input.Nullable<any> ? never : Key]: $Fields[Key] | ||
} | ||
|
||
export type PickNullableFields<$Fields extends InputFields> = { | ||
[Key in keyof $Fields as $Fields[Key] extends Input.Nullable<any> ? Key : never]: $Fields[Key] | ||
} |
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,31 @@ | ||
import type { Args } from './Args.js' | ||
import type { MaybeThunk } from './core/helpers.js' | ||
import type { Hybrid } from './Hybrid/__.js' | ||
import type { Output } from './Output/__.js' | ||
|
||
export type Field<$Type extends Output.Any, $Args extends Args<any> | null> = { | ||
type: $Type | ||
args: $Args | ||
} | ||
|
||
export const field = <$Type extends Output.Any, $Args extends null | Args<any> = null>( | ||
type: MaybeThunk<$Type>, | ||
args: $Args = null as $Args, | ||
): Field<$Type, $Args> => { | ||
return { | ||
// At type level "type" is not a thunk | ||
type: type as any, // eslint-disable-line | ||
args, | ||
} | ||
} | ||
|
||
// todo test non null union and non null interface fields | ||
export type SomeField = Field< | ||
Hybrid.Enum | Hybrid.Scalar.Any | Output.List<any> | Output.Nullable<any> | Output.Object$2<any, any>, | ||
Args<any> | null | ||
> | ||
|
||
export type SomeFields<$Keys extends string | number | symbol = string | number | symbol> = Record< | ||
$Keys, | ||
SomeField | ||
> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
export * from './types/Enum.js' | ||
export * from './types/Scalar/__.js' |
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 @@ | ||
export * as Hybrid from './_.js' |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
import type { Any } from './typeGroups.js' | ||
|
||
export * from './typeGroups.js' | ||
export * from './types/InputObject.js' | ||
export * from './types/List.js' | ||
export * from './types/Nullable.js' | ||
|
||
export const field = <$Type extends Any>(type: $Type): Field<$Type> => { | ||
return { | ||
type: type, | ||
} | ||
} | ||
|
||
export type Field<$Type extends any = any> = { | ||
type: $Type | ||
} |
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 @@ | ||
export * as Input from './Input.js' |
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,8 @@ | ||
import type { Hybrid } from '../Hybrid/__.js' | ||
import type { InputObject } from './types/InputObject.js' | ||
import type { List } from './types/List.js' | ||
import type { Nullable } from './types/Nullable.js' | ||
|
||
export type Named = Hybrid.Enum | Hybrid.Scalar.Any | InputObject | ||
|
||
export type Any = List<any> | Nullable<any> | Named |
4 changes: 2 additions & 2 deletions
4
src/Schema/NamedType/InputObjet.ts → src/Schema/Input/types/InputObject.ts
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,9 @@ | ||
import type { Base } from '../../core/helpers.js' | ||
import type { Any } from '../typeGroups.js' | ||
|
||
export type List<$InnerType extends Any> = Base.List<$InnerType> | ||
|
||
export const List = <$InnerType extends Any>(type: $InnerType): List<$InnerType> => ({ | ||
kind: `list`, | ||
type, | ||
}) |
Oops, something went wrong.