Open cinnamon-bun opened 3 years ago
As you saw in https://github.com/earthstar-project/earthstar/issues/45, nullable fields are the only option for a GraphQL server — either that or adding more types for documents with certain fields present/absent.
Copying what I wrote thre here as it's more related to earthstar-graphql:
Another way we can go, and one which could make sense for workspaceSignature, is to create multiple types e.g. PrivateWorkspaceES4Document (great name, right?), which has a non nullable workspaceSignature, and have regular ES4Document have no field at all. There would definitely be trade-offs to doing this, but the benefit is that it makes certain impossible states impossible, e.g. like having a document with no workspaceSignature in an invite only workspace.
GraphQL also has support for interfaces, so both the private workspace and public workspace document types could share a common ES4Document interface. Hmm, I quite like the sound of that, actually...
The
deleteAfter
field is optional, but earthstar-graphql returns docs withdeleteAfter: null
.I think I like
null
better actually. I might change the Earthstar spec to usenull
, thoughts? https://github.com/earthstar-project/earthstar/issues/45