create-fate 1.9.0 → 1.10.0
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/package.json +1 -1
- package/templates/fate/drizzle/client/src/ui/PostCard.tsx +6 -1
- package/templates/fate/graphql/README.md +8 -9
- package/templates/fate/graphql/client/src/ui/PostCard.tsx +6 -1
- package/templates/fate/graphql/server/README.md +2 -4
- package/templates/fate/graphql-client/README.md +6 -14
- package/templates/fate/http/client/src/ui/PostCard.tsx +6 -1
- package/templates/fate/prisma/client/src/ui/PostCard.tsx +6 -1
- package/templates/fate/void/src/ui/PostCard.tsx +6 -1
package/package.json
CHANGED
|
@@ -78,7 +78,11 @@ const CommentInput = ({
|
|
|
78
78
|
post,
|
|
79
79
|
}: {
|
|
80
80
|
error?: unknown;
|
|
81
|
-
post: {
|
|
81
|
+
post: {
|
|
82
|
+
commentCount: number;
|
|
83
|
+
comments: Deferred<{ items: ReadonlyArray<{ node: ViewRef<'Comment'> }> }>;
|
|
84
|
+
id: string;
|
|
85
|
+
};
|
|
82
86
|
}) => {
|
|
83
87
|
const fate = useFateClient();
|
|
84
88
|
const { data: session } = AuthClient.useSession();
|
|
@@ -94,6 +98,7 @@ const CommentInput = ({
|
|
|
94
98
|
|
|
95
99
|
const result = await fate.mutations.comment.add({
|
|
96
100
|
input: { content, postId: post.id },
|
|
101
|
+
insert: { into: post.comments, position: 'after' },
|
|
97
102
|
optimistic: {
|
|
98
103
|
author: user
|
|
99
104
|
? {
|
|
@@ -18,15 +18,14 @@ Read the [Getting Started Guide](https://fate.technology/guide/core-concepts) to
|
|
|
18
18
|
|
|
19
19
|
## GraphQL Types
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
and mutation names. Fate generates `client/.fate/schema.generated.ts` from that
|
|
23
|
-
schema; its `GraphQLEntities` types are used by the client views. Mutation inputs,
|
|
24
|
-
output nullability, and connection shapes also come from the schema.
|
|
21
|
+
After changing your GraphQL schema, regenerate the schema file and client types:
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
```bash
|
|
24
|
+
vp run --filter '@app/server' generate-graphql
|
|
25
|
+
vp run fate:generate
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`client/src/fate/graphql.ts` maps query and mutation names. Client views use `GraphQLEntities` from `client/.fate/schema.generated.ts`, generated from your Pothos schema. Server data views handle live updates and authorization.
|
|
30
29
|
|
|
31
30
|
## Technologies
|
|
32
31
|
|
|
@@ -126,7 +125,7 @@ Common commands from the project root:
|
|
|
126
125
|
- `vp run dev:client` starts only the client.
|
|
127
126
|
- `vp run dev:server` starts only the server.
|
|
128
127
|
- `vp run dev:setup` generates the Prisma client, Pothos schema import map, fbtee setup, and fate client support.
|
|
129
|
-
- `vp run fate:generate`
|
|
128
|
+
- `vp run fate:generate` regenerates client types after changing the GraphQL schema or client mapping.
|
|
130
129
|
- `vp run prisma` runs Prisma CLI commands in the server package.
|
|
131
130
|
- `vp check --fix` formats, lints, and type-checks the workspace.
|
|
132
131
|
- `vp test` runs the test suite.
|
|
@@ -74,7 +74,11 @@ const CommentInput = ({
|
|
|
74
74
|
post,
|
|
75
75
|
}: {
|
|
76
76
|
error?: unknown;
|
|
77
|
-
post: {
|
|
77
|
+
post: {
|
|
78
|
+
commentCount: number;
|
|
79
|
+
comments: Deferred<{ items: ReadonlyArray<{ node: ViewRef<'Comment'> }> }>;
|
|
80
|
+
id: string;
|
|
81
|
+
};
|
|
78
82
|
}) => {
|
|
79
83
|
const fate = useFateClient();
|
|
80
84
|
const { data: session } = AuthClient.useSession();
|
|
@@ -90,6 +94,7 @@ const CommentInput = ({
|
|
|
90
94
|
|
|
91
95
|
const result = await fate.mutations.comment.add({
|
|
92
96
|
input: { content, postId: post.id },
|
|
97
|
+
insert: { into: post.comments, position: 'after' },
|
|
93
98
|
optimistic: {
|
|
94
99
|
author: user
|
|
95
100
|
? {
|
|
@@ -14,7 +14,7 @@ vp run dev
|
|
|
14
14
|
|
|
15
15
|
The server defaults to `http://localhost:9000/graphql`.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
`vp run dev:setup` exports the GraphQL schema for the client. From the client directory, point the Vite plugin at the mapping module:
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
20
|
fate({
|
|
@@ -23,6 +23,4 @@ fate({
|
|
|
23
23
|
});
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
The server data views in `src/graphql/views.ts` remain responsible for live-event resolution,
|
|
28
|
-
including authorization and computed fields. They do not define the GraphQL client types.
|
|
26
|
+
fate generates client types from the schema. Server data views in `src/graphql/views.ts` handle live updates, authorization, and computed fields.
|
|
@@ -34,24 +34,16 @@ VITE_GRAPHQL_URL="https://api.example.com/graphql" vp run build
|
|
|
34
34
|
|
|
35
35
|
These `VITE_*` values are embedded in the client bundle. Do not put credentials in them. Production builds do not read `.env`.
|
|
36
36
|
|
|
37
|
-
Replace `src/fate/schema.graphql` with
|
|
38
|
-
GraphQL server, then edit `src/fate/graphql.ts` to map application names:
|
|
37
|
+
Replace `src/fate/schema.graphql` with your server's schema, then edit `src/fate/graphql.ts`:
|
|
39
38
|
|
|
40
|
-
- `fateGraphQL.schema` supplies the
|
|
41
|
-
- `fateGraphQL.roots` exposes query fields
|
|
42
|
-
through `field`. Entity and connection types are inferred from the schema.
|
|
39
|
+
- `fateGraphQL.schema` supplies the schema used to generate client types.
|
|
40
|
+
- `fateGraphQL.roots` exposes query fields. Use `field` to map a different name.
|
|
43
41
|
- `fateGraphQL.mutations` maps application mutation names to schema fields.
|
|
44
|
-
- `fateGraphQL.scalars` optionally describes custom scalar
|
|
45
|
-
custom scalars are `unknown`.
|
|
42
|
+
- `fateGraphQL.scalars` optionally describes custom scalar types, which default to `unknown`.
|
|
46
43
|
|
|
47
|
-
The sample schema includes `viewer`, `posts(first:, after:)`, `postLike(input:)`,
|
|
48
|
-
`node(id:)`, and `nodes(ids:)`, with Relay-style connections. Replace it with your
|
|
49
|
-
server's actual contract, including nullability and arguments.
|
|
44
|
+
The sample schema includes `viewer`, `posts(first:, after:)`, `postLike(input:)`, `node(id:)`, and `nodes(ids:)`, with Relay-style connections. Replace these with your server's fields and arguments.
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
use `GraphQLEntities` from that file; there are no handwritten entity or mutation
|
|
53
|
-
input types to keep synchronized. The schema and generation imports are excluded
|
|
54
|
-
from the browser client.
|
|
46
|
+
After changing the schema or mapping, run `vp run fate:generate`. Client views use `GraphQLEntities` from the generated `.fate/schema.generated.ts`. The schema stays out of the browser bundle.
|
|
55
47
|
|
|
56
48
|
## Development
|
|
57
49
|
|
|
@@ -74,7 +74,11 @@ const CommentInput = ({
|
|
|
74
74
|
post,
|
|
75
75
|
}: {
|
|
76
76
|
error?: unknown;
|
|
77
|
-
post: {
|
|
77
|
+
post: {
|
|
78
|
+
commentCount: number;
|
|
79
|
+
comments: Deferred<{ items: ReadonlyArray<{ node: ViewRef<'Comment'> }> }>;
|
|
80
|
+
id: string;
|
|
81
|
+
};
|
|
78
82
|
}) => {
|
|
79
83
|
const fate = useFateClient();
|
|
80
84
|
const { data: session } = AuthClient.useSession();
|
|
@@ -90,6 +94,7 @@ const CommentInput = ({
|
|
|
90
94
|
|
|
91
95
|
const result = await fate.mutations.comment.add({
|
|
92
96
|
input: { content, postId: post.id },
|
|
97
|
+
insert: { into: post.comments, position: 'after' },
|
|
93
98
|
optimistic: {
|
|
94
99
|
author: user
|
|
95
100
|
? {
|
|
@@ -74,7 +74,11 @@ const CommentInput = ({
|
|
|
74
74
|
post,
|
|
75
75
|
}: {
|
|
76
76
|
error?: unknown;
|
|
77
|
-
post: {
|
|
77
|
+
post: {
|
|
78
|
+
commentCount: number;
|
|
79
|
+
comments: Deferred<{ items: ReadonlyArray<{ node: ViewRef<'Comment'> }> }>;
|
|
80
|
+
id: string;
|
|
81
|
+
};
|
|
78
82
|
}) => {
|
|
79
83
|
const fate = useFateClient();
|
|
80
84
|
const { data: session } = AuthClient.useSession();
|
|
@@ -90,6 +94,7 @@ const CommentInput = ({
|
|
|
90
94
|
|
|
91
95
|
const result = await fate.mutations.comment.add({
|
|
92
96
|
input: { content, postId: post.id },
|
|
97
|
+
insert: { into: post.comments, position: 'after' },
|
|
93
98
|
optimistic: {
|
|
94
99
|
author: user
|
|
95
100
|
? {
|
|
@@ -92,7 +92,11 @@ const CommentInput = ({
|
|
|
92
92
|
post,
|
|
93
93
|
}: {
|
|
94
94
|
error?: unknown;
|
|
95
|
-
post: {
|
|
95
|
+
post: {
|
|
96
|
+
commentCount: number;
|
|
97
|
+
comments: Deferred<{ items: ReadonlyArray<{ node: ViewRef<'Comment'> }> }>;
|
|
98
|
+
id: string;
|
|
99
|
+
};
|
|
96
100
|
}) => {
|
|
97
101
|
const fate = useFateClient();
|
|
98
102
|
const { auth } = useShared<SharedData>();
|
|
@@ -108,6 +112,7 @@ const CommentInput = ({
|
|
|
108
112
|
|
|
109
113
|
const result = await fate.mutations.comment.add({
|
|
110
114
|
input: { content, postId: post.id },
|
|
115
|
+
insert: { into: post.comments, position: 'after' },
|
|
111
116
|
optimistic: {
|
|
112
117
|
author: user ? { id: user.id, name: user.name } : null,
|
|
113
118
|
content,
|