Summary
Right now, users interact with a types/ folder that contains ~a file per node, and then Fuse generates a fuse/ folder that people use from their client(s). (import { useQuery } from '@/fuse/client')
Proposed Solution
I propose we centralize all of it into the fuse/ folders. Users write their types in their, and then we also generate the files in there and they import from there from the client.
First idea for a potential folder structure:
.
└── fuse/
├── User.ts
├── Product.ts
├── _context.ts
└── _generated/
├── client.ts
├── fragment-masking.ts
├── gql.ts
├── graphql.ts
├── index.ts
├── pages.ts
└── server.ts
The big question is what happens to the client imports. With this structure, they'd look like import { useQuery } from '@/fuse/_generated/client', which isn't great.
Since client.ts, index.ts, pages.ts, and server.ts are simple re-exports of the underlying libraries and the really truly generated custom files are fragment-masking.ts, gql.ts, and graphql.ts, we could try this folder structure instead:
.
└── fuse/
├── User.ts
├── Product.ts
├── client.ts
├── index.ts
├── pages.ts
├── server.ts
├── context.ts
└── generated/
├── fragment-masking.ts
├── gql.ts
└── graphql.ts
This would fully preserve the client imports while centralizing everything else. The downside of this is that the index/pages/server/client.ts files get muddled with the types/nodes, and it's a bit of an odd semantics because users are meant to touch context.ts but not server.ts — that's not intuitive.
Another option that clearly marks index/pages/server/client.ts distinct from the types files would be to prefix them with a _, just like we do with _generated and _context in the original example:
.
└── fuse/
├── User.ts
├── Product.ts
├── context.ts
├── _client.ts
├── _index.ts
├── _pages.ts
├── _server.ts
└── _generated/
├── fragment-masking.ts
├── gql.ts
└── graphql.ts
But that makes client-side imports ugly. import from '@/fuse/_client 😕 Also, _index.ts obviously doesn't work for import from '@/fuse' so we'd need a different name for those exports.
Any other ideas?
Summary
Right now, users interact with a
types/folder that contains ~a file per node, and then Fuse generates afuse/folder that people use from their client(s). (import { useQuery } from '@/fuse/client')Proposed Solution
I propose we centralize all of it into the
fuse/folders. Users write their types in their, and then we also generate the files in there and they import from there from the client.First idea for a potential folder structure:
The big question is what happens to the client imports. With this structure, they'd look like
import { useQuery } from '@/fuse/_generated/client', which isn't great.Since
client.ts,index.ts,pages.ts, andserver.tsare simple re-exports of the underlying libraries and the really truly generated custom files arefragment-masking.ts,gql.ts, andgraphql.ts, we could try this folder structure instead:This would fully preserve the client imports while centralizing everything else. The downside of this is that the
index/pages/server/client.tsfiles get muddled with the types/nodes, and it's a bit of an odd semantics because users are meant to touchcontext.tsbut notserver.ts— that's not intuitive.Another option that clearly marks
index/pages/server/client.tsdistinct from the types files would be to prefix them with a_, just like we do with_generatedand_contextin the original example:But that makes client-side imports ugly.
import from '@/fuse/_client😕 Also,_index.tsobviously doesn't work forimport from '@/fuse'so we'd need a different name for those exports.Any other ideas?