Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ent/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Ent models
# Ent

## Schema

This directory contains the Ent schema definitions used by the application.

Expand All @@ -16,7 +18,7 @@ Why the two-step process
2. Generate files from `ent/schema` without privacy policies.
3. Generate files from `ent/authschema` to create the final files.

## Adding a new schema
### Adding a new schema

To add a new schema:

Expand All @@ -34,3 +36,8 @@ To add a new schema:
4. Add tests for the privacy policies in `ent/authschema/privacy_test.go`.
5. Run `./tools/update_schema.sh` to regenerate the code with the new schema
and policies.

## Templates

Templates used by Ent live in `ent/template`. These are used to change the code
that Ent generates. When updating Ent, these probably need to be updated.
9 changes: 9 additions & 0 deletions ent/entc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ import (
"github.com/hedwigz/entviz"
)

func getGqlTemplates() []*gen.Template {
customPaginationTemplate := gen.MustParse(gen.NewTemplate("./ent/template/pagination.tmpl").
Funcs(entgql.TemplateFuncs).
ParseFiles("./ent/template/pagination.tmpl"),
)
return append(entgql.AllTemplates, customPaginationTemplate)
}

func main() {
ex, err := entgql.NewExtension(
entgql.WithTemplates(getGqlTemplates()...),
entgql.WithSchemaGenerator(),
entgql.WithSchemaPath("./internal/graphql/schema/ent.graphql"),
entgql.WithWhereInputs(true),
Expand Down
Loading
Loading