mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
doc: add page for codegen feature-flags (#1023)
This commit is contained in:
@@ -230,3 +230,9 @@ func EnsureStructTag(name string) gen.Hook {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Feature Flags
|
||||
|
||||
The `entc` package provides a collection of code-generation features that be added or removed using flags.
|
||||
|
||||
For more information, please see the [features-flags page](features.md).
|
||||
|
||||
74
doc/md/features.md
Normal file
74
doc/md/features.md
Normal file
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: feature-flags
|
||||
title: Feature Flags
|
||||
sidebar_label: Feature Flags
|
||||
---
|
||||
|
||||
The framework provides a collection of code-generation features that be added or removed using flags.
|
||||
|
||||
## Usage
|
||||
|
||||
Feature flags can be provided either by CLI flags or as arguments to the `gen` package.
|
||||
|
||||
#### CLI
|
||||
|
||||
```console
|
||||
go run github.com/facebook/ent/cmd/ent generate --feature privacy,entql ./ent/schema
|
||||
```
|
||||
|
||||
#### Go
|
||||
|
||||
```go
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"text/template"
|
||||
|
||||
"github.com/facebook/ent/entc"
|
||||
"github.com/facebook/ent/entc/gen"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := entc.Generate("./schema", &gen.Config{
|
||||
Features: []*gen.Feature{
|
||||
gen.FeaturePrivacy,
|
||||
gen.FeatureEntQL,
|
||||
},
|
||||
Templates: []*gen.Template{
|
||||
gen.MustParse(gen.NewTemplate("static").
|
||||
Funcs(template.FuncMap{"title": strings.ToTitle}).
|
||||
ParseFiles("template/static.tmpl")),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("running ent codegen: %v", err)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## List of Features
|
||||
|
||||
#### Privacy Layer
|
||||
|
||||
The privacy layer allows configuring privacy policy for queries and mutations of entities in the database.
|
||||
|
||||
This option can be added to projects using the `--feature privacy` flag, and its full documentation exists
|
||||
in the [privacy page](privacy.md).
|
||||
|
||||
#### EntQL Filtering
|
||||
|
||||
The `entql` option provides a generic and dynamic filtering capability at runtime for the different query builders.
|
||||
|
||||
This option can be added to projects using the `--feature entql` flag, and more information about it exists
|
||||
in the [privacy page](privacy.md#multi-tenancy).
|
||||
|
||||
#### Auto-Solve Merge Conflicts
|
||||
|
||||
The `schema/snapshot` option tells `entc` (ent codegen) to store a snapshot of the latest schema in an internal package,
|
||||
and use it to automatically solve merge conflicts when user's schema can't be built.
|
||||
|
||||
This option can be added to projects using the `--feature schema/snapshot` flag, but please see
|
||||
[facebook/ent/issues/852](https://github.com/facebook/ent/issues/852) to get more context about it.
|
||||
@@ -32,7 +32,8 @@
|
||||
"graphql",
|
||||
"sql-integration",
|
||||
"testing",
|
||||
"faq"
|
||||
"faq",
|
||||
"feature-flags"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user