@isograph/react 0.0.0-main-6efaacee → 0.0.0-main-1de01fd0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/reader.d.ts +3 -3
- package/package.json +3 -3
- package/src/reader.ts +4 -4
- package/src/tests/__isograph/iso.ts +7 -7
package/dist/reader.d.ts
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
import { ComponentOrFieldName, IsographEnvironment } from './IsographEnvironment';
|
3
3
|
import { RefetchQueryNormalizationArtifact } from './entrypoint';
|
4
4
|
import { Arguments } from './util';
|
5
|
-
export type TopLevelReaderArtifact<TReadFromStore extends Object, TClientFieldValue,
|
5
|
+
export type TopLevelReaderArtifact<TReadFromStore extends Object, TClientFieldValue, TComponentProps extends Record<string, never>> = EagerReaderArtifact<TReadFromStore, TClientFieldValue> | ComponentReaderArtifact<TReadFromStore, TComponentProps>;
|
6
6
|
export type EagerReaderArtifact<TReadFromStore extends Object, TClientFieldValue> = {
|
7
7
|
readonly kind: 'EagerReaderArtifact';
|
8
8
|
readonly readerAst: ReaderAst<TReadFromStore>;
|
9
9
|
readonly resolver: (data: TReadFromStore) => TClientFieldValue;
|
10
10
|
};
|
11
|
-
export type ComponentReaderArtifact<TReadFromStore extends Object,
|
11
|
+
export type ComponentReaderArtifact<TReadFromStore extends Object, TComponentProps extends Record<string, unknown> = Record<string, never>> = {
|
12
12
|
readonly kind: 'ComponentReaderArtifact';
|
13
13
|
readonly componentName: ComponentOrFieldName;
|
14
14
|
readonly readerAst: ReaderAst<TReadFromStore>;
|
15
|
-
readonly resolver: (data: TReadFromStore, runtimeProps:
|
15
|
+
readonly resolver: (data: TReadFromStore, runtimeProps: TComponentProps) => React.ReactNode;
|
16
16
|
};
|
17
17
|
export type RefetchReaderArtifact = {
|
18
18
|
readonly kind: 'RefetchReaderArtifact';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@isograph/react",
|
3
|
-
"version": "0.0.0-main-
|
3
|
+
"version": "0.0.0-main-1de01fd0",
|
4
4
|
"description": "Use Isograph with React",
|
5
5
|
"homepage": "https://isograph.dev",
|
6
6
|
"main": "dist/index.js",
|
@@ -16,8 +16,8 @@
|
|
16
16
|
"prepack": "yarn run test && yarn run compile"
|
17
17
|
},
|
18
18
|
"dependencies": {
|
19
|
-
"@isograph/disposable-types": "0.0.0-main-
|
20
|
-
"@isograph/react-disposable-state": "0.0.0-main-
|
19
|
+
"@isograph/disposable-types": "0.0.0-main-1de01fd0",
|
20
|
+
"@isograph/react-disposable-state": "0.0.0-main-1de01fd0",
|
21
21
|
"react": "^18.2.0"
|
22
22
|
},
|
23
23
|
"devDependencies": {
|
package/src/reader.ts
CHANGED
@@ -8,10 +8,10 @@ import { Arguments } from './util';
|
|
8
8
|
export type TopLevelReaderArtifact<
|
9
9
|
TReadFromStore extends Object,
|
10
10
|
TClientFieldValue,
|
11
|
-
|
11
|
+
TComponentProps extends Record<string, never>,
|
12
12
|
> =
|
13
13
|
| EagerReaderArtifact<TReadFromStore, TClientFieldValue>
|
14
|
-
| ComponentReaderArtifact<TReadFromStore,
|
14
|
+
| ComponentReaderArtifact<TReadFromStore, TComponentProps>;
|
15
15
|
|
16
16
|
export type EagerReaderArtifact<
|
17
17
|
TReadFromStore extends Object,
|
@@ -24,14 +24,14 @@ export type EagerReaderArtifact<
|
|
24
24
|
|
25
25
|
export type ComponentReaderArtifact<
|
26
26
|
TReadFromStore extends Object,
|
27
|
-
|
27
|
+
TComponentProps extends Record<string, unknown> = Record<string, never>,
|
28
28
|
> = {
|
29
29
|
readonly kind: 'ComponentReaderArtifact';
|
30
30
|
readonly componentName: ComponentOrFieldName;
|
31
31
|
readonly readerAst: ReaderAst<TReadFromStore>;
|
32
32
|
readonly resolver: (
|
33
33
|
data: TReadFromStore,
|
34
|
-
runtimeProps:
|
34
|
+
runtimeProps: TComponentProps,
|
35
35
|
) => React.ReactNode;
|
36
36
|
};
|
37
37
|
|
@@ -11,19 +11,19 @@ import entrypoint_Query__nodeField from '../__isograph/Query/nodeField/entrypoin
|
|
11
11
|
// the type of the passed-in function, which takes one parameter
|
12
12
|
// of type TParam.
|
13
13
|
type IdentityWithParam<TParam> = <TClientFieldReturn>(
|
14
|
-
|
14
|
+
clientField: (param: TParam) => TClientFieldReturn
|
15
15
|
) => (param: TParam) => TClientFieldReturn;
|
16
16
|
|
17
17
|
// This is the type given it to client fields with @component.
|
18
18
|
// This means that the type of the exported iso literal is exactly
|
19
19
|
// the type of the passed-in function, which takes two parameters.
|
20
|
-
// The first has type TParam, and the second has type
|
20
|
+
// The first has type TParam, and the second has type TComponentProps.
|
21
21
|
//
|
22
|
-
//
|
22
|
+
// TComponentProps becomes the types of the props you must pass
|
23
23
|
// whenever the @component field is rendered.
|
24
|
-
type IdentityWithParamComponent<TParam> = <TClientFieldReturn,
|
25
|
-
|
26
|
-
) => (data: TParam,
|
24
|
+
type IdentityWithParamComponent<TParam> = <TClientFieldReturn, TComponentProps = Record<string, never>>(
|
25
|
+
clientComponentField: (data: TParam, componentProps: TComponentProps) => TClientFieldReturn
|
26
|
+
) => (data: TParam, componentProps: TComponentProps) => TClientFieldReturn;
|
27
27
|
|
28
28
|
type WhitespaceCharacter = ' ' | '\t' | '\n';
|
29
29
|
type Whitespace<In> = In extends `${WhitespaceCharacter}${infer In}`
|
@@ -34,7 +34,7 @@ type Whitespace<In> = In extends `${WhitespaceCharacter}${infer In}`
|
|
34
34
|
// start with whitespace, followed by TString. So e.g. if we have
|
35
35
|
// ```
|
36
36
|
// export function iso<T>(
|
37
|
-
//
|
37
|
+
// isographLiteralText: T & MatchesWhitespaceAndString<'field Query.foo', T>
|
38
38
|
// ): Bar;
|
39
39
|
// ```
|
40
40
|
// then, when you call
|