-
-
Notifications
You must be signed in to change notification settings - Fork 3
Description
TLDR for the @fauna team: Compiled suggestions on how to improve Fauna and fix this issue can be found here.
Currently, in order to generate TS types (faugra generate-types
and faugra build-sdk
), faugra makes some compromises that won't be acceptable to the general audience.
The problem
Given a schema file, faugra uploads its content to fauna in order to:
have any missing "base" schema appended to it (it adds e.g.scalar Date
anddirective @resolve
)--> primitive values are being hardcoded into base.gql instead.- have the schema expanded with the basic CRUD methods (e.g.
findAll<Type>ByID
)
Without uploading the schema to the cloud the TS types would be incomplete , lacking the content that fauna adds to it.
Current solution
Putting all together, in order to generate the TS types, faugra needs to:
- prepare the schema (which potentially comes from a merge of multiple files)
- upload the basic schema (requires credentials and can have serious unintended consequences)
- download the expanded one (requires credentials)
- run graphql-codegen
As modularisation is a core principle of faugra we need to repeat this process for each file individually (--> We had to give up on that because of this issue). But, if we do not reset the database before pushing the new schema in, fauna will merge the content of the files. The last schema uploaded will in practice extend the content of all schema files pushed before. Therefore, importing the schema in override mode is a must.
Considerations
Considering the performance and side effects of steps $2 and $3 I believe that I can't have the TS types being generated "on save", as I initially planned. And, after all considered, I wonder if anyone would actually bother going through the hassle of setting up such tool that requires credentials and mess with your data.
So, we need to find a way to kill steps $2 and $3: we need to programmatically add the missing content in the basic schema instead of publishing it to the cloud.
Where do we start? 🙃