create-fate 1.9.0 → 1.10.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fate",
3
- "version": "1.9.0",
3
+ "version": "1.10.1",
4
4
  "description": "Create a new fate app.",
5
5
  "homepage": "https://github.com/nkzw-tech/fate",
6
6
  "license": "MIT",
@@ -78,7 +78,11 @@ const CommentInput = ({
78
78
  post,
79
79
  }: {
80
80
  error?: unknown;
81
- post: { commentCount: number; id: string };
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
- `client/src/fate/graphql.ts` imports the SDL exported from the Pothos schema during `dev:setup` and maps application root
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
- Run `vp run --filter '@app/server' generate-graphql` after changing schema fields,
27
- then `vp run fate:generate` to update the client contracts. The server's
28
- Prisma data views implement live-event resolution and authorization; they are
29
- independent of these generated client contracts.
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` refreshes fate client support after changing server views, roots, or routers.
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: { commentCount: number; id: string };
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
- The client mapping imports the SDL exported from the Pothos schema during `dev:setup`. From the client directory, configure the Vite plugin with:
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
- Fate derives entity fields, connection roots, mutation inputs, and selected results from the schema.
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 the schema exported by your existing
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 SDL used during generation.
41
- - `fateGraphQL.roots` exposes query fields and optionally maps different names
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 wire types. Unmapped
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
- Run `vp run fate:generate` to generate `.fate/schema.generated.ts`. Client views
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: { commentCount: number; id: string };
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: { commentCount: number; id: string };
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
  ? {
@@ -1,3 +1,4 @@
1
+ -- void:allow-destructive
1
2
  DROP INDEX `account_issuer_accountId_key`;
2
3
  --> statement-breakpoint
3
4
  ALTER TABLE `account` DROP COLUMN `issuer`;
@@ -92,7 +92,11 @@ const CommentInput = ({
92
92
  post,
93
93
  }: {
94
94
  error?: unknown;
95
- post: { commentCount: number; id: string };
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,