-
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.
- Loading branch information
1 parent
420a389
commit 98cb065
Showing
8 changed files
with
61 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from '../../client/client.js' | ||
// todo need to export a generated version | ||
export { create as createSelect } from '../../select.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
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,13 @@ | ||
import { expect, it } from 'vitest' | ||
import type { Index } from '../tests/ts/_/schema/generated/Index.js' | ||
import { create } from './select.js' | ||
|
||
it(`returns the input for any method name`, () => { | ||
const select = create() as any // eslint-disable-line | ||
expect(select.anything(1)).toEqual(1) // eslint-disable-line | ||
}) | ||
|
||
it(`has type safe methods`, () => { | ||
const select = create<Index>() | ||
expect(select.Bar({ ___: { $defer: true, int: true } })).toEqual({ ___: { $defer: true, int: true } }) | ||
}) |
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,35 @@ | ||
import type { SelectionSet } from './client/SelectionSet/__.js' | ||
import type { Exact } from './lib/prelude.js' | ||
import type { Schema } from './Schema/__.js' | ||
|
||
// todo test | ||
// dprint-ignore | ||
export type Select<$Index extends Schema.Index> = | ||
& { | ||
[$RootTypeName in Schema.RootTypeName]: | ||
<$SelectionSet extends object>(selectionSet: Exact<$SelectionSet, SelectionSet.Root<$Index, $RootTypeName>>) => | ||
$SelectionSet | ||
} | ||
& { | ||
[$Name in keyof $Index['objects']]: | ||
<$SelectionSet extends object>(selectionSet: Exact<$SelectionSet, SelectionSet.Object<$Index['objects'][$Name], $Index>>) => | ||
$SelectionSet | ||
} | ||
& { | ||
[$Name in keyof $Index['unions']]: | ||
<$SelectionSet extends object>(selectionSet: Exact<$SelectionSet, SelectionSet.Union<$Index['unions'][$Name], $Index>>) => | ||
$SelectionSet | ||
} | ||
& { | ||
[$Name in keyof Schema.Index['interfaces']]: | ||
<$SelectionSet extends object>(selectionSet: Exact<$SelectionSet, SelectionSet.Interface<$Index['interfaces'][$Name], $Index>>) => | ||
$SelectionSet | ||
} | ||
|
||
export const create = <$Index extends Schema.Index>(): Select<$Index> => { | ||
return idProxy as any | ||
} | ||
|
||
const idProxy = new Proxy({}, { | ||
get: () => (value: unknown) => value, | ||
}) |
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