Global Filters¶
Global filters are repository-level filters that Suite applies automatically to queries. They are useful for cross-cutting rules such as hiding inactive records or restricting records by sharing level.
Global filters are enabled by default. Use IGlobalFilterContext when a query
needs to opt out of one or more filters.
Disabling filters¶
Inject IGlobalFilterContext in application code, consumers, GraphQL middleware,
or other orchestration code that needs to control filter behavior.
The context exposes scoped disable operations. Once the returned scope is disposed, the previous filter state is restored.
| C# | |
|---|---|
Disabling multiple filters¶
GlobalFilters is a flags enum, so filters can be combined.
| C# | |
|---|---|
To disable every global filter, omit the argument or pass GlobalFilters.All.
| C# | |
|---|---|
GraphQL fields¶
GraphQL query fields can use DisableFiltersAttribute when the filter policy is
static for that field. The attribute receives the filters that must be disabled
while the field resolves.
Disable all global filters:
| C# | |
|---|---|
Disable only sharing-level filtering while keeping activation, tenant, and custom filters active:
| C# | |
|---|---|
Disable more than one filter:
| C# | |
|---|---|
Available filters¶
The current filter flags are:
| Flag | Description |
|---|---|
GlobalFilters.SharingLevels |
Controls the sharing level query filter. |
GlobalFilters.Activation |
Controls the activation query filter for deactivatable entities. |
GlobalFilters.Tenant |
Reserved for tenant filtering. |
GlobalFilters.Custom |
Default bucket for custom providers that do not declare a more specific flag. |
GlobalFilters.All |
Disables every registered global filter. |
Adding a filter provider¶
Global filter providers implement IGlobalFilterSpecificationProvider. Providers
should declare which flag controls them by implementing the Filter property.
The repository infrastructure uses IGlobalFilterSpecificationManager
internally to collect provider specifications. Application code should use
IGlobalFilterContext instead; that keeps repository internals out of
application services, consumers, and middleware.
Module-specific contexts¶
Some modules still expose a module-specific context because they do more than
enable or disable a repository filter. For example, sharing code uses
ISharingsContextManager for behavior outside query filtering, such as
calculating destination sharing levels.
Use IGlobalFilterContext for query filter control. Use the module-specific
context only when you need the module behavior it owns.