2020-04-24 10:55:51 +03:00
|
|
|
-- | The RQL query ('/v1/query')
|
2021-11-04 19:08:33 +03:00
|
|
|
module Hasura.Server.API.Query
|
|
|
|
( RQLQuery,
|
|
|
|
queryModifiesSchemaCache,
|
|
|
|
requiresAdmin,
|
|
|
|
runQuery,
|
|
|
|
)
|
|
|
|
where
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2021-05-27 18:06:13 +03:00
|
|
|
import Control.Monad.Trans.Control (MonadBaseControl)
|
2023-06-28 10:54:05 +03:00
|
|
|
import Data.Aeson qualified as J
|
|
|
|
import Data.Aeson.Casing qualified as J (snakeCase)
|
2021-05-27 18:06:13 +03:00
|
|
|
import Data.Environment qualified as Env
|
2021-09-09 14:54:19 +03:00
|
|
|
import Data.Has (Has)
|
Clean `AppEnv` and `AppContext` passing, remove `RunT`, reduce `ServerConfigCtx` uses
## Description
This PR does several different things that happen to overlap; the most important being:
- it removes `RunT`: it was redundant in places where we already had `Handler`, and only used in one other place, `SchemaUpdate`, for which a local `SchemaUpdateT` is more than enough;
- it reduces the number of places where we create a `ServerConfigCtx`, since now `HasServerConfigCtx` can be implemented directly by `SchemaUpdateT` and `Handler` based on the full `AppContext`;
- it drastically reduces the number of arguments we pass around in the app init code, by introducing `HasAppEnv`;
- it simplifies `HandlerCtx` to reduce duplication
In doing so, this changes paves the way towards removing `ServerConfigCtx`, since there are only very few places where we construct it: we can now introduce smaller classes than `HasServerConfigCtx`, that expose only a relevant subset of fields, and implement them where we now implement `HasServerConfigCtx`.
This PR is loosely based on ideas in #8337, that are no longer applicable due to the changes introduced in #8159. A challenge of this PR was the postgres tests, which were running in `PGMetadataStorageAppT CacheBuild` :scream_cat:
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8392
GitOrigin-RevId: b90c1359066d20dbea329c87762ccdd1217b4d69
2023-03-21 13:44:21 +03:00
|
|
|
import Hasura.App.State
|
2021-05-27 18:06:13 +03:00
|
|
|
import Hasura.Backends.Postgres.DDL.RunSQL
|
2021-05-11 18:18:31 +03:00
|
|
|
import Hasura.Base.Error
|
2019-03-18 19:22:21 +03:00
|
|
|
import Hasura.EncJSON
|
2023-04-03 13:18:54 +03:00
|
|
|
import Hasura.Function.API qualified as Functions
|
2021-05-27 18:06:13 +03:00
|
|
|
import Hasura.Logging qualified as L
|
2020-12-14 07:30:19 +03:00
|
|
|
import Hasura.Metadata.Class
|
2021-01-09 02:09:15 +03:00
|
|
|
import Hasura.Prelude
|
2023-03-31 00:18:11 +03:00
|
|
|
import Hasura.QueryTags
|
2020-02-13 20:38:23 +03:00
|
|
|
import Hasura.RQL.DDL.Action
|
2019-10-18 11:29:47 +03:00
|
|
|
import Hasura.RQL.DDL.ComputedField
|
2020-02-13 20:38:23 +03:00
|
|
|
import Hasura.RQL.DDL.CustomTypes
|
2021-01-29 04:02:34 +03:00
|
|
|
import Hasura.RQL.DDL.Endpoint
|
2019-04-17 19:29:39 +03:00
|
|
|
import Hasura.RQL.DDL.EventTrigger
|
2018-06-27 16:11:32 +03:00
|
|
|
import Hasura.RQL.DDL.Metadata
|
|
|
|
import Hasura.RQL.DDL.Permission
|
2019-05-16 09:13:25 +03:00
|
|
|
import Hasura.RQL.DDL.QueryCollection
|
2018-06-27 16:11:32 +03:00
|
|
|
import Hasura.RQL.DDL.Relationship
|
2019-03-01 12:17:22 +03:00
|
|
|
import Hasura.RQL.DDL.Relationship.Rename
|
2020-05-27 18:02:58 +03:00
|
|
|
import Hasura.RQL.DDL.RemoteRelationship
|
2020-05-13 15:33:16 +03:00
|
|
|
import Hasura.RQL.DDL.ScheduledTrigger
|
2019-08-14 02:34:37 +03:00
|
|
|
import Hasura.RQL.DDL.Schema
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
import Hasura.RQL.DDL.Schema.Cache.Config
|
2018-12-13 10:26:15 +03:00
|
|
|
import Hasura.RQL.DML.Count
|
|
|
|
import Hasura.RQL.DML.Delete
|
|
|
|
import Hasura.RQL.DML.Insert
|
|
|
|
import Hasura.RQL.DML.Select
|
2020-11-12 12:25:48 +03:00
|
|
|
import Hasura.RQL.DML.Types
|
2018-12-13 10:26:15 +03:00
|
|
|
import Hasura.RQL.DML.Update
|
2022-04-27 16:57:28 +03:00
|
|
|
import Hasura.RQL.Types.Allowlist
|
2023-04-24 21:35:48 +03:00
|
|
|
import Hasura.RQL.Types.BackendType
|
2022-04-27 16:57:28 +03:00
|
|
|
import Hasura.RQL.Types.Common
|
|
|
|
import Hasura.RQL.Types.CustomTypes
|
2022-03-13 10:40:06 +03:00
|
|
|
import Hasura.RQL.Types.Endpoint
|
2022-04-27 16:57:28 +03:00
|
|
|
import Hasura.RQL.Types.Metadata
|
|
|
|
import Hasura.RQL.Types.Permission
|
|
|
|
import Hasura.RQL.Types.QueryCollection
|
|
|
|
import Hasura.RQL.Types.ScheduledTrigger
|
2023-03-28 16:26:08 +03:00
|
|
|
import Hasura.RQL.Types.SchemaCache
|
2022-04-27 16:57:28 +03:00
|
|
|
import Hasura.RQL.Types.SchemaCache.Build
|
|
|
|
import Hasura.RQL.Types.Source
|
scaffolding for remote-schemas module
The main aim of the PR is:
1. To set up a module structure for 'remote-schemas' package.
2. Move parts by the remote schema codebase into the new module structure to validate it.
## Notes to the reviewer
Why a PR with large-ish diff?
1. We've been making progress on the MM project but we don't yet know long it is going to take us to get to the first milestone. To understand this better, we need to figure out the unknowns as soon as possible. Hence I've taken a stab at the first two items in the [end-state](https://gist.github.com/0x777/ca2bdc4284d21c3eec153b51dea255c9) document to figure out the unknowns. Unsurprisingly, there are a bunch of issues that we haven't discussed earlier. These are documented in the 'open questions' section.
1. The diff is large but that is only code moved around and I've added a section that documents how things are moved. In addition, there are fair number of PR comments to help with the review process.
## Changes in the PR
### Module structure
Sets up the module structure as follows:
```
Hasura/
RemoteSchema/
Metadata/
Types.hs
SchemaCache/
Types.hs
Permission.hs
RemoteRelationship.hs
Build.hs
MetadataAPI/
Types.hs
Execute.hs
```
### 1. Types representing metadata are moved
Types that capture metadata information (currently scattered across several RQL modules) are moved into `Hasura.RemoteSchema.Metadata.Types`.
- This new module only depends on very 'core' modules such as
`Hasura.Session` for the notion of roles and `Hasura.Incremental` for `Cacheable` typeclass.
- The requirement on database modules is avoided by generalizing the remote schemas metadata to accept an arbitrary 'r' for a remote relationship
definition.
### 2. SchemaCache related types and build logic have been moved
Types that represent remote schemas information in SchemaCache are moved into `Hasura.RemoteSchema.SchemaCache.Types`.
Similar to `H.RS.Metadata.Types`, this module depends on 'core' modules except for `Hasura.GraphQL.Parser.Variable`. It has something to do with remote relationships but I haven't spent time looking into it. The validation of 'remote relationships to remote schema' is also something that needs to be looked at.
Rips out the logic that builds remote schema's SchemaCache information from the monolithic `buildSchemaCacheRule` and moves it into `Hasura.RemoteSchema.SchemaCache.Build`. Further, the `.SchemaCache.Permission` and `.SchemaCache.RemoteRelationship` have been created from existing modules that capture schema cache building logic for those two components.
This was a fair amount of work. On main, currently remote schema's SchemaCache information is built in two phases - in the first phase, 'permissions' and 'remote relationships' are ignored and in the second phase they are filled in.
While remote relationships can only be resolved after partially resolving sources and other remote schemas, the same isn't true for permissions. Further, most of the work that is done to resolve remote relationships can be moved to the first phase so that the second phase can be a very simple traversal.
This is the approach that was taken - resolve permissions and as much as remote relationships information in the first phase.
### 3. Metadata APIs related types and build logic have been moved
The types that represent remote schema related metadata APIs and the execution logic have been moved to `Hasura.RemoteSchema.MetadataAPI.Types` and `.Execute` modules respectively.
## Open questions:
1. `Hasura.RemoteSchema.Metadata.Types` is so called because I was hoping that all of the metadata related APIs of remote schema can be brought in at `Hasura.RemoteSchema.Metadata.API`. However, as metadata APIs depended on functions from `SchemaCache` module (see [1](https://github.com/hasura/graphql-engine-mono/blob/ceba6d62264603ee5d279814677b29bcc43ecaea/server/src-lib/Hasura/RQL/DDL/RemoteSchema.hs#L55) and [2](https://github.com/hasura/graphql-engine-mono/blob/ceba6d62264603ee5d279814677b29bcc43ecaea/server/src-lib/Hasura/RQL/DDL/RemoteSchema.hs#L91), it made more sense to create a separate top-level module for `MetadataAPI`s.
Maybe we can just have `Hasura.RemoteSchema.Metadata` and get rid of the extra nesting or have `Hasura.RemoteSchema.Metadata.{Core,Permission,RemoteRelationship}` if we want to break them down further.
1. `buildRemoteSchemas` in `H.RS.SchemaCache.Build` has the following type:
```haskell
buildRemoteSchemas ::
( ArrowChoice arr,
Inc.ArrowDistribute arr,
ArrowWriter (Seq CollectedInfo) arr,
Inc.ArrowCache m arr,
MonadIO m,
HasHttpManagerM m,
Inc.Cacheable remoteRelationshipDefinition,
ToJSON remoteRelationshipDefinition,
MonadError QErr m
) =>
Env.Environment ->
( (Inc.Dependency (HashMap RemoteSchemaName Inc.InvalidationKey), OrderedRoles),
[RemoteSchemaMetadataG remoteRelationshipDefinition]
)
`arr` HashMap RemoteSchemaName (PartiallyResolvedRemoteSchemaCtxG remoteRelationshipDefinition, MetadataObject)
```
Note the dependence on `CollectedInfo` which is defined as
```haskell
data CollectedInfo
= CIInconsistency InconsistentMetadata
| CIDependency
MetadataObject
-- ^ for error reporting on missing dependencies
SchemaObjId
SchemaDependency
deriving (Eq)
```
this pretty much means that remote schemas is dependent on types from databases, actions, ....
How do we fix this? Maybe introduce a typeclass such as `ArrowCollectRemoteSchemaDependencies` which is defined in `Hasura.RemoteSchema` and then implemented in graphql-engine?
1. The dependency on `buildSchemaCacheFor` in `.MetadataAPI.Execute` which has the following signature:
```haskell
buildSchemaCacheFor ::
(QErrM m, CacheRWM m, MetadataM m) =>
MetadataObjId ->
MetadataModifier ->
```
This can be easily resolved if we restrict what the metadata APIs are allowed to do. Currently, they operate in an unfettered access to modify SchemaCache (the `CacheRWM` constraint):
```haskell
runAddRemoteSchema ::
( QErrM m,
CacheRWM m,
MonadIO m,
HasHttpManagerM m,
MetadataM m,
Tracing.MonadTrace m
) =>
Env.Environment ->
AddRemoteSchemaQuery ->
m EncJSON
```
This should instead be changed to restrict remote schema APIs to only modify remote schema metadata (but has access to the remote schemas part of the schema cache), this dependency is completely removed.
```haskell
runAddRemoteSchema ::
( QErrM m,
MonadIO m,
HasHttpManagerM m,
MonadReader RemoteSchemasSchemaCache m,
MonadState RemoteSchemaMetadata m,
Tracing.MonadTrace m
) =>
Env.Environment ->
AddRemoteSchemaQuery ->
m RemoteSchemeMetadataObjId
```
The idea is that the core graphql-engine would call these functions and then call
`buildSchemaCacheFor`.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6291
GitOrigin-RevId: 51357148c6404afe70219afa71bd1d59bdf4ffc6
2022-10-21 06:13:07 +03:00
|
|
|
import Hasura.RemoteSchema.MetadataAPI
|
[Preview] Inherited roles for postgres read queries
fixes #3868
docker image - `hasura/graphql-engine:inherited-roles-preview-48b73a2de`
Note:
To be able to use the inherited roles feature, the graphql-engine should be started with the env variable `HASURA_GRAPHQL_EXPERIMENTAL_FEATURES` set to `inherited_roles`.
Introduction
------------
This PR implements the idea of multiple roles as presented in this [paper](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/FGALanguageICDE07.pdf). The multiple roles feature in this PR can be used via inherited roles. An inherited role is a role which can be created by combining multiple singular roles. For example, if there are two roles `author` and `editor` configured in the graphql-engine, then we can create a inherited role with the name of `combined_author_editor` role which will combine the select permissions of the `author` and `editor` roles and then make GraphQL queries using the `combined_author_editor`.
How are select permissions of different roles are combined?
------------------------------------------------------------
A select permission includes 5 things:
1. Columns accessible to the role
2. Row selection filter
3. Limit
4. Allow aggregation
5. Scalar computed fields accessible to the role
Suppose there are two roles, `role1` gives access to the `address` column with row filter `P1` and `role2` gives access to both the `address` and the `phone` column with row filter `P2` and we create a new role `combined_roles` which combines `role1` and `role2`.
Let's say the following GraphQL query is queried with the `combined_roles` role.
```graphql
query {
employees {
address
phone
}
}
```
This will translate to the following SQL query:
```sql
select
(case when (P1 or P2) then address else null end) as address,
(case when P2 then phone else null end) as phone
from employee
where (P1 or P2)
```
The other parameters of the select permission will be combined in the following manner:
1. Limit - Minimum of the limits will be the limit of the inherited role
2. Allow aggregations - If any of the role allows aggregation, then the inherited role will allow aggregation
3. Scalar computed fields - same as table column fields, as in the above example
APIs for inherited roles:
----------------------
1. `add_inherited_role`
`add_inherited_role` is the [metadata API](https://hasura.io/docs/1.0/graphql/core/api-reference/index.html#schema-metadata-api) to create a new inherited role. It accepts two arguments
`role_name`: the name of the inherited role to be added (String)
`role_set`: list of roles that need to be combined (Array of Strings)
Example:
```json
{
"type": "add_inherited_role",
"args": {
"role_name":"combined_user",
"role_set":[
"user",
"user1"
]
}
}
```
After adding the inherited role, the inherited role can be used like single roles like earlier
Note:
An inherited role can only be created with non-inherited/singular roles.
2. `drop_inherited_role`
The `drop_inherited_role` API accepts the name of the inherited role and drops it from the metadata. It accepts a single argument:
`role_name`: name of the inherited role to be dropped
Example:
```json
{
"type": "drop_inherited_role",
"args": {
"role_name":"combined_user"
}
}
```
Metadata
---------
The derived roles metadata will be included under the `experimental_features` key while exporting the metadata.
```json
{
"experimental_features": {
"derived_roles": [
{
"role_name": "manager_is_employee_too",
"role_set": [
"employee",
"manager"
]
}
]
}
}
```
Scope
------
Only postgres queries and subscriptions are supported in this PR.
Important points:
-----------------
1. All columns exposed to an inherited role will be marked as `nullable`, this is done so that cell value nullification can be done.
TODOs
-------
- [ ] Tests
- [ ] Test a GraphQL query running with a inherited role without enabling inherited roles in experimental features
- [] Tests for aggregate queries, limit, computed fields, functions, subscriptions (?)
- [ ] Introspection test with a inherited role (nullability changes in a inherited role)
- [ ] Docs
- [ ] Changelog
Co-authored-by: Vamshi Surabhi <6562944+0x777@users.noreply.github.com>
GitOrigin-RevId: 3b8ee1e11f5ceca80fe294f8c074d42fbccfec63
2021-03-08 14:14:13 +03:00
|
|
|
import Hasura.Server.Types
|
2019-03-01 14:45:04 +03:00
|
|
|
import Hasura.Server.Utils
|
harmonize network manager handling
## Description
### I want to speak to the `Manager`
Oh boy. This PR is both fairly straightforward and overreaching, so let's break it down.
For most network access, we need a [`HTTP.Manager`](https://hackage.haskell.org/package/http-client-0.1.0.0/docs/Network-HTTP-Client-Manager.html). It is created only once, at the top level, when starting the engine, and is then threaded through the application to wherever we need to make a network call. As of main, the way we do this is not standardized: most of the GraphQL execution code passes it "manually" as a function argument throughout the code. We also have a custom monad constraint, `HasHttpManagerM`, that describes a monad's ability to provide a manager. And, finally, several parts of the code store the manager in some kind of argument structure, such as `RunT`'s `RunCtx`.
This PR's first goal is to harmonize all of this: we always create the manager at the root, and we already have it when we do our very first `runReaderT`. Wouldn't it make sense for the rest of the code to not manually pass it anywhere, to not store it anywhere, but to always rely on the current monad providing it? This is, in short, what this PR does: it implements a constraint on the base monads, so that they provide the manager, and removes most explicit passing from the code.
### First come, first served
One way this PR goes a tiny bit further than "just" doing the aforementioned harmonization is that it starts the process of implementing the "Services oriented architecture" roughly outlined in this [draft document](https://docs.google.com/document/d/1FAigqrST0juU1WcT4HIxJxe1iEBwTuBZodTaeUvsKqQ/edit?usp=sharing). Instead of using the existing `HasHTTPManagerM`, this PR revamps it into the `ProvidesNetwork` service.
The idea is, again, that we should make all "external" dependencies of the engine, all things that the core of the engine doesn't care about, a "service". This allows us to define clear APIs for features, to choose different implementations based on which version of the engine we're running, harmonizes our many scattered monadic constraints... Which is why this service is called "Network": we can refine it, moving forward, to be the constraint that defines how all network communication is to operate, instead of relying on disparate classes constraint or hardcoded decisions. A comment in the code clarifies this intent.
### Side-effects? In my Haskell?
This PR also unavoidably touches some other aspects of the codebase. One such example: it introduces `Hasura.App.AppContext`, named after `HasuraPro.Context.AppContext`: a name for the reader structure at the base level. It also transforms `Handler` from a type alias to a newtype, as `Handler` is where we actually enforce HTTP limits; but without `Handler` being a distinct type, any code path could simply do a `runExceptT $ runReader` and forget to enforce them.
(As a rule of thumb, i am starting to consider any straggling `runReaderT` or `runExceptT` as a code smell: we should not stack / unstack monads haphazardly, and every layer should be an opaque `newtype` with a corresponding run function.)
## Further work
In several places, i have left TODOs when i have encountered things that suggest that we should do further unrelated cleanups. I'll write down the follow-up steps, either in the aforementioned document or on slack. But, in short, at a glance, in approximate order, we could:
- delete `ExecutionCtx` as it is only a subset of `ServerCtx`, and remove one more `runReaderT` call
- delete `ServerConfigCtx` as it is only a subset of `ServerCtx`, and remove it from `RunCtx`
- remove `ServerCtx` from `HandlerCtx`, and make it part of `AppContext`, or even make it the `AppContext` altogether (since, at least for the OSS version, `AppContext` is there again only a subset)
- remove `CacheBuildParams` and `CacheBuild` altogether, as they're just a distinct stack that is a `ReaderT` on top of `IO` that contains, you guessed it, the same thing as `ServerCtx`
- move `RunT` out of `RQL.Types` and rename it, since after the previous cleanups **it only contains `UserInfo`**; it could be bundled with the authentication service, made a small implementation detail in `Hasura.Server.Auth`
- rename `PGMetadaStorageT` to something a bit more accurate, such as `App`, and enforce its IO base
This would significantly simply our complex stack. From there, or in parallel, we can start moving existing dependencies as Services. For the purpose of supporting read replicas entitlement, we could move `MonadResolveSource` to a `SourceResolver` service, as attempted in #7653, and transform `UserAuthenticationM` into a `Authentication` service.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7736
GitOrigin-RevId: 68cce710eb9e7d752bda1ba0c49541d24df8209f
2023-02-22 18:53:52 +03:00
|
|
|
import Hasura.Services
|
2020-04-24 12:10:53 +03:00
|
|
|
import Hasura.Session
|
2021-07-29 11:29:12 +03:00
|
|
|
import Hasura.Tracing qualified as Tracing
|
2021-05-11 18:18:31 +03:00
|
|
|
|
2019-09-19 07:47:36 +03:00
|
|
|
data RQLQueryV1
|
2021-04-22 00:44:37 +03:00
|
|
|
= RQAddExistingTableOrView !(TrackTable ('Postgres 'Vanilla))
|
|
|
|
| RQTrackTable !(TrackTable ('Postgres 'Vanilla))
|
|
|
|
| RQUntrackTable !(UntrackTable ('Postgres 'Vanilla))
|
2022-10-11 12:08:04 +03:00
|
|
|
| RQSetTableIsEnum !(SetTableIsEnum ('Postgres 'Vanilla))
|
2021-06-17 16:21:55 +03:00
|
|
|
| RQSetTableCustomization !(SetTableCustomization ('Postgres 'Vanilla))
|
2023-04-03 13:18:54 +03:00
|
|
|
| RQTrackFunction !(Functions.TrackFunction ('Postgres 'Vanilla))
|
|
|
|
| RQUntrackFunction !(Functions.UnTrackFunction ('Postgres 'Vanilla))
|
2021-04-22 00:44:37 +03:00
|
|
|
| RQCreateObjectRelationship !(CreateObjRel ('Postgres 'Vanilla))
|
|
|
|
| RQCreateArrayRelationship !(CreateArrRel ('Postgres 'Vanilla))
|
|
|
|
| RQDropRelationship !(DropRel ('Postgres 'Vanilla))
|
|
|
|
| RQSetRelationshipComment !(SetRelComment ('Postgres 'Vanilla))
|
|
|
|
| RQRenameRelationship !(RenameRel ('Postgres 'Vanilla))
|
2019-10-18 11:29:47 +03:00
|
|
|
| -- computed fields related
|
2021-04-22 00:44:37 +03:00
|
|
|
RQAddComputedField !(AddComputedField ('Postgres 'Vanilla))
|
|
|
|
| RQDropComputedField !(DropComputedField ('Postgres 'Vanilla))
|
Fix several issues with remote relationships.
## Remaining Work
- [x] changelog entry
- [x] more tests: `<backend>_delete_remote_relationship` is definitely untested
- [x] negative tests: we probably want to assert that there are some APIs we DON'T support
- [x] update the console to use the new API, if necessary
- [x] ~~adding the corresponding documentation for the API for other backends (only `pg_` was added here)~~
- deferred to https://github.com/hasura/graphql-engine-mono/issues/3170
- [x] ~~deciding which backends should support this API~~
- deferred to https://github.com/hasura/graphql-engine-mono/issues/3170
- [x] ~~deciding what to do about potentially overlapping schematic representations~~
- ~~cf. https://github.com/hasura/graphql-engine-mono/pull/3157#issuecomment-995307624~~
- deferred to https://github.com/hasura/graphql-engine-mono/issues/3171
- [x] ~~add more descriptive versioning information to some of the types that are changing in this PR~~
- cf. https://github.com/hasura/graphql-engine-mono/pull/3157#discussion_r769830920
- deferred to https://github.com/hasura/graphql-engine-mono/issues/3172
## Description
This PR fixes several important issues wrt. the remote relationship API.
- it fixes a regression introduced by [#3124](https://github.com/hasura/graphql-engine-mono/pull/3124), which prevented `<backend>_create_remote_relationship` from accepting the old argument format (break of backwards compatibility, broke the console)
- it removes the command `create_remote_relationship` added to the v1/metadata API as a work-around as part of [#3124](https://github.com/hasura/graphql-engine-mono/pull/3124)
- it reverts the subsequent fix in the console: [#3149](https://github.com/hasura/graphql-engine-mono/pull/3149)
Furthermore, this PR also addresses two other issues:
- THE DOCUMENTATION OF THE METADATA API WAS WRONG, and documented `create_remote_relationship` instead of `<backend>_create_remote_relationship`: this PR fixes this by adding `pg_` everywhere, but does not attempt to add the corresponding documentation for other backends, partly because:
- `<backend>_delete_remote_relationship` WAS BROKEN ON NON-POSTGRES BACKENDS; it always expected an argument parameterized by Postgres.
As of main, the `<backend>_(create|update|delete)_remote_relationship` commands are supported on Postgres, Citus, BigQuery, but **NOT MSSQL**. I do not know if this is intentional or not, if it even should be publicized or not, and as a result this PR doesn't change this.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3157
Co-authored-by: jkachmar <8461423+jkachmar@users.noreply.github.com>
GitOrigin-RevId: 37e2f41522a9229a11c595574c3f4984317d652a
2021-12-16 23:28:08 +03:00
|
|
|
| RQCreateRemoteRelationship !(CreateFromSourceRelationship ('Postgres 'Vanilla))
|
|
|
|
| RQUpdateRemoteRelationship !(CreateFromSourceRelationship ('Postgres 'Vanilla))
|
2021-12-01 07:53:34 +03:00
|
|
|
| RQDeleteRemoteRelationship !(DeleteFromSourceRelationship ('Postgres 'Vanilla))
|
2021-06-09 22:42:37 +03:00
|
|
|
| RQCreateInsertPermission !(CreatePerm InsPerm ('Postgres 'Vanilla))
|
|
|
|
| RQCreateSelectPermission !(CreatePerm SelPerm ('Postgres 'Vanilla))
|
|
|
|
| RQCreateUpdatePermission !(CreatePerm UpdPerm ('Postgres 'Vanilla))
|
|
|
|
| RQCreateDeletePermission !(CreatePerm DelPerm ('Postgres 'Vanilla))
|
2022-04-06 15:47:35 +03:00
|
|
|
| RQDropInsertPermission !(DropPerm ('Postgres 'Vanilla))
|
|
|
|
| RQDropSelectPermission !(DropPerm ('Postgres 'Vanilla))
|
|
|
|
| RQDropUpdatePermission !(DropPerm ('Postgres 'Vanilla))
|
|
|
|
| RQDropDeletePermission !(DropPerm ('Postgres 'Vanilla))
|
2021-04-22 00:44:37 +03:00
|
|
|
| RQSetPermissionComment !(SetPermComment ('Postgres 'Vanilla))
|
2019-04-17 19:29:39 +03:00
|
|
|
| RQGetInconsistentMetadata !GetInconsistentMetadata
|
|
|
|
| RQDropInconsistentMetadata !DropInconsistentMetadata
|
2018-06-27 16:11:32 +03:00
|
|
|
| RQInsert !InsertQuery
|
|
|
|
| RQSelect !SelectQuery
|
|
|
|
| RQUpdate !UpdateQuery
|
|
|
|
| RQDelete !DeleteQuery
|
|
|
|
| RQCount !CountQuery
|
|
|
|
| RQBulk ![RQLQuery]
|
2018-11-23 16:02:46 +03:00
|
|
|
| -- schema-stitching, custom resolver related
|
|
|
|
RQAddRemoteSchema !AddRemoteSchemaQuery
|
2021-06-21 20:41:43 +03:00
|
|
|
| RQUpdateRemoteSchema !AddRemoteSchemaQuery
|
2019-07-08 08:51:41 +03:00
|
|
|
| RQRemoveRemoteSchema !RemoteSchemaNameQuery
|
|
|
|
| RQReloadRemoteSchema !RemoteSchemaNameQuery
|
2020-05-27 18:02:58 +03:00
|
|
|
| RQIntrospectRemoteSchema !RemoteSchemaNameQuery
|
2021-04-22 00:44:37 +03:00
|
|
|
| RQCreateEventTrigger !(CreateEventTriggerQuery ('Postgres 'Vanilla))
|
|
|
|
| RQDeleteEventTrigger !(DeleteEventTriggerQuery ('Postgres 'Vanilla))
|
|
|
|
| RQRedeliverEvent !(RedeliverEventQuery ('Postgres 'Vanilla))
|
|
|
|
| RQInvokeEventTrigger !(InvokeEventTriggerQuery ('Postgres 'Vanilla))
|
2020-05-13 15:33:16 +03:00
|
|
|
| -- scheduled triggers
|
|
|
|
RQCreateCronTrigger !CreateCronTrigger
|
|
|
|
| RQDeleteCronTrigger !ScheduledTriggerName
|
|
|
|
| RQCreateScheduledEvent !CreateScheduledEvent
|
2019-05-16 09:13:25 +03:00
|
|
|
| -- query collections, allow list related
|
|
|
|
RQCreateQueryCollection !CreateCollection
|
2022-08-19 16:36:02 +03:00
|
|
|
| RQRenameQueryCollection !RenameCollection
|
2019-05-16 09:13:25 +03:00
|
|
|
| RQDropQueryCollection !DropCollection
|
|
|
|
| RQAddQueryToCollection !AddQueryToCollection
|
|
|
|
| RQDropQueryFromCollection !DropQueryFromCollection
|
2022-02-08 19:53:30 +03:00
|
|
|
| RQAddCollectionToAllowlist !AllowlistEntry
|
|
|
|
| RQDropCollectionFromAllowlist !DropCollectionFromAllowlist
|
2018-06-27 16:11:32 +03:00
|
|
|
| RQRunSql !RunSQL
|
2020-12-28 15:56:00 +03:00
|
|
|
| RQReplaceMetadata !ReplaceMetadata
|
2018-06-27 16:11:32 +03:00
|
|
|
| RQExportMetadata !ExportMetadata
|
|
|
|
| RQClearMetadata !ClearMetadata
|
2018-09-05 18:25:30 +03:00
|
|
|
| RQReloadMetadata !ReloadMetadata
|
2020-02-13 20:38:23 +03:00
|
|
|
| RQCreateAction !CreateAction
|
|
|
|
| RQDropAction !DropAction
|
|
|
|
| RQUpdateAction !UpdateAction
|
|
|
|
| RQCreateActionPermission !CreateActionPermission
|
|
|
|
| RQDropActionPermission !DropActionPermission
|
2021-01-29 04:02:34 +03:00
|
|
|
| RQCreateRestEndpoint !CreateEndpoint
|
|
|
|
| RQDropRestEndpoint !DropEndpoint
|
2018-06-27 16:11:32 +03:00
|
|
|
| RQDumpInternalState !DumpInternalState
|
2020-02-13 20:38:23 +03:00
|
|
|
| RQSetCustomTypes !CustomTypes
|
2023-06-28 10:54:05 +03:00
|
|
|
deriving stock (Generic)
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2019-09-19 07:47:36 +03:00
|
|
|
data RQLQueryV2
|
2021-04-22 00:44:37 +03:00
|
|
|
= RQV2TrackTable !(TrackTableV2 ('Postgres 'Vanilla))
|
2020-10-29 15:48:45 +03:00
|
|
|
| RQV2SetTableCustomFields !SetTableCustomFields -- deprecated
|
2023-04-03 13:18:54 +03:00
|
|
|
| RQV2TrackFunction !(Functions.TrackFunctionV2 ('Postgres 'Vanilla))
|
2021-02-16 11:08:19 +03:00
|
|
|
| RQV2ReplaceMetadata !ReplaceMetadataV2
|
2023-06-28 10:54:05 +03:00
|
|
|
deriving stock (Generic)
|
2019-09-19 07:47:36 +03:00
|
|
|
|
|
|
|
data RQLQuery
|
|
|
|
= RQV1 !RQLQueryV1
|
|
|
|
| RQV2 !RQLQueryV2
|
|
|
|
|
2023-06-28 10:54:05 +03:00
|
|
|
instance J.FromJSON RQLQuery where
|
|
|
|
parseJSON = J.withObject "Object" $ \o -> do
|
|
|
|
mVersion <- o J..:? "version"
|
|
|
|
let version = fromMaybe VIVersion1 mVersion
|
|
|
|
val = J.Object o
|
|
|
|
case version of
|
|
|
|
VIVersion1 -> RQV1 <$> J.parseJSON val
|
|
|
|
VIVersion2 -> RQV2 <$> J.parseJSON val
|
|
|
|
|
|
|
|
instance J.FromJSON RQLQueryV1 where
|
|
|
|
parseJSON =
|
|
|
|
J.genericParseJSON
|
|
|
|
J.defaultOptions
|
|
|
|
{ J.constructorTagModifier = J.snakeCase . drop 2,
|
|
|
|
J.sumEncoding = J.TaggedObject "type" "args"
|
|
|
|
}
|
|
|
|
|
|
|
|
instance J.FromJSON RQLQueryV2 where
|
|
|
|
parseJSON =
|
|
|
|
J.genericParseJSON
|
|
|
|
J.defaultOptions
|
|
|
|
{ J.constructorTagModifier = J.snakeCase . drop 4,
|
|
|
|
J.sumEncoding = J.TaggedObject "type" "args",
|
|
|
|
J.tagSingleConstructors = True
|
|
|
|
}
|
2018-06-27 16:11:32 +03:00
|
|
|
|
|
|
|
runQuery ::
|
2021-10-13 19:38:56 +03:00
|
|
|
( MonadIO m,
|
2023-02-03 04:03:23 +03:00
|
|
|
MonadError QErr m,
|
Clean `AppEnv` and `AppContext` passing, remove `RunT`, reduce `ServerConfigCtx` uses
## Description
This PR does several different things that happen to overlap; the most important being:
- it removes `RunT`: it was redundant in places where we already had `Handler`, and only used in one other place, `SchemaUpdate`, for which a local `SchemaUpdateT` is more than enough;
- it reduces the number of places where we create a `ServerConfigCtx`, since now `HasServerConfigCtx` can be implemented directly by `SchemaUpdateT` and `Handler` based on the full `AppContext`;
- it drastically reduces the number of arguments we pass around in the app init code, by introducing `HasAppEnv`;
- it simplifies `HandlerCtx` to reduce duplication
In doing so, this changes paves the way towards removing `ServerConfigCtx`, since there are only very few places where we construct it: we can now introduce smaller classes than `HasServerConfigCtx`, that expose only a relevant subset of fields, and implement them where we now implement `HasServerConfigCtx`.
This PR is loosely based on ideas in #8337, that are no longer applicable due to the changes introduced in #8159. A challenge of this PR was the postgres tests, which were running in `PGMetadataStorageAppT CacheBuild` :scream_cat:
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8392
GitOrigin-RevId: b90c1359066d20dbea329c87762ccdd1217b4d69
2023-03-21 13:44:21 +03:00
|
|
|
HasAppEnv m,
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
HasCacheStaticConfig m,
|
2020-12-14 07:30:19 +03:00
|
|
|
Tracing.MonadTrace m,
|
|
|
|
MonadBaseControl IO m,
|
2023-04-03 16:35:15 +03:00
|
|
|
MonadMetadataStorage m,
|
2020-12-28 15:56:00 +03:00
|
|
|
MonadResolveSource m,
|
2022-09-15 14:45:14 +03:00
|
|
|
MonadQueryTags m,
|
harmonize network manager handling
## Description
### I want to speak to the `Manager`
Oh boy. This PR is both fairly straightforward and overreaching, so let's break it down.
For most network access, we need a [`HTTP.Manager`](https://hackage.haskell.org/package/http-client-0.1.0.0/docs/Network-HTTP-Client-Manager.html). It is created only once, at the top level, when starting the engine, and is then threaded through the application to wherever we need to make a network call. As of main, the way we do this is not standardized: most of the GraphQL execution code passes it "manually" as a function argument throughout the code. We also have a custom monad constraint, `HasHttpManagerM`, that describes a monad's ability to provide a manager. And, finally, several parts of the code store the manager in some kind of argument structure, such as `RunT`'s `RunCtx`.
This PR's first goal is to harmonize all of this: we always create the manager at the root, and we already have it when we do our very first `runReaderT`. Wouldn't it make sense for the rest of the code to not manually pass it anywhere, to not store it anywhere, but to always rely on the current monad providing it? This is, in short, what this PR does: it implements a constraint on the base monads, so that they provide the manager, and removes most explicit passing from the code.
### First come, first served
One way this PR goes a tiny bit further than "just" doing the aforementioned harmonization is that it starts the process of implementing the "Services oriented architecture" roughly outlined in this [draft document](https://docs.google.com/document/d/1FAigqrST0juU1WcT4HIxJxe1iEBwTuBZodTaeUvsKqQ/edit?usp=sharing). Instead of using the existing `HasHTTPManagerM`, this PR revamps it into the `ProvidesNetwork` service.
The idea is, again, that we should make all "external" dependencies of the engine, all things that the core of the engine doesn't care about, a "service". This allows us to define clear APIs for features, to choose different implementations based on which version of the engine we're running, harmonizes our many scattered monadic constraints... Which is why this service is called "Network": we can refine it, moving forward, to be the constraint that defines how all network communication is to operate, instead of relying on disparate classes constraint or hardcoded decisions. A comment in the code clarifies this intent.
### Side-effects? In my Haskell?
This PR also unavoidably touches some other aspects of the codebase. One such example: it introduces `Hasura.App.AppContext`, named after `HasuraPro.Context.AppContext`: a name for the reader structure at the base level. It also transforms `Handler` from a type alias to a newtype, as `Handler` is where we actually enforce HTTP limits; but without `Handler` being a distinct type, any code path could simply do a `runExceptT $ runReader` and forget to enforce them.
(As a rule of thumb, i am starting to consider any straggling `runReaderT` or `runExceptT` as a code smell: we should not stack / unstack monads haphazardly, and every layer should be an opaque `newtype` with a corresponding run function.)
## Further work
In several places, i have left TODOs when i have encountered things that suggest that we should do further unrelated cleanups. I'll write down the follow-up steps, either in the aforementioned document or on slack. But, in short, at a glance, in approximate order, we could:
- delete `ExecutionCtx` as it is only a subset of `ServerCtx`, and remove one more `runReaderT` call
- delete `ServerConfigCtx` as it is only a subset of `ServerCtx`, and remove it from `RunCtx`
- remove `ServerCtx` from `HandlerCtx`, and make it part of `AppContext`, or even make it the `AppContext` altogether (since, at least for the OSS version, `AppContext` is there again only a subset)
- remove `CacheBuildParams` and `CacheBuild` altogether, as they're just a distinct stack that is a `ReaderT` on top of `IO` that contains, you guessed it, the same thing as `ServerCtx`
- move `RunT` out of `RQL.Types` and rename it, since after the previous cleanups **it only contains `UserInfo`**; it could be bundled with the authentication service, made a small implementation detail in `Hasura.Server.Auth`
- rename `PGMetadaStorageT` to something a bit more accurate, such as `App`, and enforce its IO base
This would significantly simply our complex stack. From there, or in parallel, we can start moving existing dependencies as Services. For the purpose of supporting read replicas entitlement, we could move `MonadResolveSource` to a `SourceResolver` service, as attempted in #7653, and transform `UserAuthenticationM` into a `Authentication` service.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7736
GitOrigin-RevId: 68cce710eb9e7d752bda1ba0c49541d24df8209f
2023-02-22 18:53:52 +03:00
|
|
|
MonadEventLogCleanup m,
|
2023-03-13 14:44:18 +03:00
|
|
|
ProvidesHasuraServices m,
|
2023-05-11 08:19:42 +03:00
|
|
|
MonadGetPolicies m,
|
Remove `HasServerConfigCtx` from the schema cache build.
## Description
This PR is a incremental step towards achieving the goal of #8344. It is a less ambitious version of #8484.
This PR removes all references to `HasServerConfigCtx` from the cache build and removes `ServerConfigCtx` from `CacheBuildParams`, making `ServerConfigCtx` an argument being passed around manually instead. This has several benefits: by making it an arrow argument, we now properly integrate the fields that change over time in the dependency framework, as they should be, and we can clean up some of the top-level app code.
## Implementation
In practice, this PR introduces a `HasServerConfigCtx` instance for `CacheRWT`, the monad we use to build the cache, so we can retrieve the `ServerConfigCtx` in the implementation of `CacheRWM`. This contributes to reducing the amount of `HasServerConfigCtx` in the code: we can remove `SchemaUpdateT` altogether, and we can remove the `HasServerConfigCtx` instance of `Handler`. This makes `HasServerConfigCtx` almost **an implementation detail of the Metadata API**.
This first step is enough to achieve the goal of #8344: we can now build the schema cache in the app monad, since we no longer rely on `HasServerConfigCtx` to build it.
## Drawbacks
This PR does not attempt to remove the use of `ServerConfigCtx` itself in the schema cache build: doing so would make this PR much much bigger. Ideally, to avoid having all the static fields given as arrow-ish arguments to the cache, we could depend on `HasAppEnv` in the cache build, and use `AppContext` as an arrow argument. But making the cache build depend on the full `AppEnv` and `AppContext` creates a lot of circular imports; and since removing `ServerConfigCtx` itself isn't required to achieve #8344, this PR keeps it wholesale and defers cleaning it to a future PR.
A negative consequence of this is that we need an `Eq` instance on `ServerConfigCtx`, and that instance is inelegant.
## Future work
There are several further steps we can take in parallel after this is merged. First, again, we can make a new version of #8344, removing `CacheBuild`, FINALLY. As for `ServerConfigCtx`, we can split it / rename it to make ad-hoc structures. If it turns out that `ServerConfigCtx` is only ever used for the schema cache build, we could split it between `CacheBuildEnv` and `CacheBuildContext`, which will be subsets of `AppEnv` and `AppContext`, avoiding import loops.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8509
GitOrigin-RevId: 01b37cc3fd3490d6b117701e22fc4ac88b62b6b5
2023-03-27 20:42:37 +03:00
|
|
|
UserInfoM m
|
2020-12-14 07:30:19 +03:00
|
|
|
) =>
|
Clean `AppEnv` and `AppContext` passing, remove `RunT`, reduce `ServerConfigCtx` uses
## Description
This PR does several different things that happen to overlap; the most important being:
- it removes `RunT`: it was redundant in places where we already had `Handler`, and only used in one other place, `SchemaUpdate`, for which a local `SchemaUpdateT` is more than enough;
- it reduces the number of places where we create a `ServerConfigCtx`, since now `HasServerConfigCtx` can be implemented directly by `SchemaUpdateT` and `Handler` based on the full `AppContext`;
- it drastically reduces the number of arguments we pass around in the app init code, by introducing `HasAppEnv`;
- it simplifies `HandlerCtx` to reduce duplication
In doing so, this changes paves the way towards removing `ServerConfigCtx`, since there are only very few places where we construct it: we can now introduce smaller classes than `HasServerConfigCtx`, that expose only a relevant subset of fields, and implement them where we now implement `HasServerConfigCtx`.
This PR is loosely based on ideas in #8337, that are no longer applicable due to the changes introduced in #8159. A challenge of this PR was the postgres tests, which were running in `PGMetadataStorageAppT CacheBuild` :scream_cat:
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8392
GitOrigin-RevId: b90c1359066d20dbea329c87762ccdd1217b4d69
2023-03-21 13:44:21 +03:00
|
|
|
AppContext ->
|
2020-12-14 07:30:19 +03:00
|
|
|
RebuildableSchemaCache ->
|
2021-02-18 19:46:14 +03:00
|
|
|
RQLQuery ->
|
|
|
|
m (EncJSON, RebuildableSchemaCache)
|
Clean `AppEnv` and `AppContext` passing, remove `RunT`, reduce `ServerConfigCtx` uses
## Description
This PR does several different things that happen to overlap; the most important being:
- it removes `RunT`: it was redundant in places where we already had `Handler`, and only used in one other place, `SchemaUpdate`, for which a local `SchemaUpdateT` is more than enough;
- it reduces the number of places where we create a `ServerConfigCtx`, since now `HasServerConfigCtx` can be implemented directly by `SchemaUpdateT` and `Handler` based on the full `AppContext`;
- it drastically reduces the number of arguments we pass around in the app init code, by introducing `HasAppEnv`;
- it simplifies `HandlerCtx` to reduce duplication
In doing so, this changes paves the way towards removing `ServerConfigCtx`, since there are only very few places where we construct it: we can now introduce smaller classes than `HasServerConfigCtx`, that expose only a relevant subset of fields, and implement them where we now implement `HasServerConfigCtx`.
This PR is loosely based on ideas in #8337, that are no longer applicable due to the changes introduced in #8159. A challenge of this PR was the postgres tests, which were running in `PGMetadataStorageAppT CacheBuild` :scream_cat:
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8392
GitOrigin-RevId: b90c1359066d20dbea329c87762ccdd1217b4d69
2023-03-21 13:44:21 +03:00
|
|
|
runQuery appContext sc query = do
|
2023-04-27 17:30:23 +03:00
|
|
|
AppEnv {..} <- askAppEnv
|
Clean `AppEnv` and `AppContext` passing, remove `RunT`, reduce `ServerConfigCtx` uses
## Description
This PR does several different things that happen to overlap; the most important being:
- it removes `RunT`: it was redundant in places where we already had `Handler`, and only used in one other place, `SchemaUpdate`, for which a local `SchemaUpdateT` is more than enough;
- it reduces the number of places where we create a `ServerConfigCtx`, since now `HasServerConfigCtx` can be implemented directly by `SchemaUpdateT` and `Handler` based on the full `AppContext`;
- it drastically reduces the number of arguments we pass around in the app init code, by introducing `HasAppEnv`;
- it simplifies `HandlerCtx` to reduce duplication
In doing so, this changes paves the way towards removing `ServerConfigCtx`, since there are only very few places where we construct it: we can now introduce smaller classes than `HasServerConfigCtx`, that expose only a relevant subset of fields, and implement them where we now implement `HasServerConfigCtx`.
This PR is loosely based on ideas in #8337, that are no longer applicable due to the changes introduced in #8159. A challenge of this PR was the postgres tests, which were running in `PGMetadataStorageAppT CacheBuild` :scream_cat:
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8392
GitOrigin-RevId: b90c1359066d20dbea329c87762ccdd1217b4d69
2023-03-21 13:44:21 +03:00
|
|
|
let logger = _lsLogger appEnvLoggers
|
2023-05-24 16:51:56 +03:00
|
|
|
when ((appEnvEnableReadOnlyMode == ReadOnlyModeEnabled) && queryModifiesUserDB query)
|
|
|
|
$ throw400 NotSupported "Cannot run write queries when read-only mode is enabled"
|
2021-12-08 09:26:46 +03:00
|
|
|
|
2022-10-20 15:45:31 +03:00
|
|
|
let exportsMetadata = \case
|
|
|
|
RQV1 (RQExportMetadata _) -> True
|
|
|
|
_ -> False
|
|
|
|
metadataDefaults =
|
|
|
|
if (exportsMetadata query)
|
|
|
|
then emptyMetadataDefaults
|
Clean `AppEnv` and `AppContext` passing, remove `RunT`, reduce `ServerConfigCtx` uses
## Description
This PR does several different things that happen to overlap; the most important being:
- it removes `RunT`: it was redundant in places where we already had `Handler`, and only used in one other place, `SchemaUpdate`, for which a local `SchemaUpdateT` is more than enough;
- it reduces the number of places where we create a `ServerConfigCtx`, since now `HasServerConfigCtx` can be implemented directly by `SchemaUpdateT` and `Handler` based on the full `AppContext`;
- it drastically reduces the number of arguments we pass around in the app init code, by introducing `HasAppEnv`;
- it simplifies `HandlerCtx` to reduce duplication
In doing so, this changes paves the way towards removing `ServerConfigCtx`, since there are only very few places where we construct it: we can now introduce smaller classes than `HasServerConfigCtx`, that expose only a relevant subset of fields, and implement them where we now implement `HasServerConfigCtx`.
This PR is loosely based on ideas in #8337, that are no longer applicable due to the changes introduced in #8159. A challenge of this PR was the postgres tests, which were running in `PGMetadataStorageAppT CacheBuild` :scream_cat:
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8392
GitOrigin-RevId: b90c1359066d20dbea329c87762ccdd1217b4d69
2023-03-21 13:44:21 +03:00
|
|
|
else acMetadataDefaults appContext
|
2023-04-27 17:30:23 +03:00
|
|
|
let dynamicConfig = buildCacheDynamicConfig appContext
|
2022-10-20 15:45:31 +03:00
|
|
|
|
2023-03-28 16:26:08 +03:00
|
|
|
MetadataWithResourceVersion metadata currentResourceVersion <- liftEitherM fetchMetadata
|
2023-06-26 13:55:11 +03:00
|
|
|
((result, updatedMetadata), modSchemaCache, invalidations, sourcesIntrospection, schemaRegistryAction) <-
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
runQueryM (acEnvironment appContext) (acSQLGenCtx appContext) query
|
Clean `AppEnv` and `AppContext` passing, remove `RunT`, reduce `ServerConfigCtx` uses
## Description
This PR does several different things that happen to overlap; the most important being:
- it removes `RunT`: it was redundant in places where we already had `Handler`, and only used in one other place, `SchemaUpdate`, for which a local `SchemaUpdateT` is more than enough;
- it reduces the number of places where we create a `ServerConfigCtx`, since now `HasServerConfigCtx` can be implemented directly by `SchemaUpdateT` and `Handler` based on the full `AppContext`;
- it drastically reduces the number of arguments we pass around in the app init code, by introducing `HasAppEnv`;
- it simplifies `HandlerCtx` to reduce duplication
In doing so, this changes paves the way towards removing `ServerConfigCtx`, since there are only very few places where we construct it: we can now introduce smaller classes than `HasServerConfigCtx`, that expose only a relevant subset of fields, and implement them where we now implement `HasServerConfigCtx`.
This PR is loosely based on ideas in #8337, that are no longer applicable due to the changes introduced in #8159. A challenge of this PR was the postgres tests, which were running in `PGMetadataStorageAppT CacheBuild` :scream_cat:
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8392
GitOrigin-RevId: b90c1359066d20dbea329c87762ccdd1217b4d69
2023-03-21 13:44:21 +03:00
|
|
|
-- TODO: remove this straight runReaderT that provides no actual new info
|
|
|
|
& flip runReaderT logger
|
|
|
|
& runMetadataT metadata metadataDefaults
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
& runCacheRWT dynamicConfig sc
|
2023-06-26 13:55:11 +03:00
|
|
|
if queryModifiesSchemaCache query
|
|
|
|
then case appEnvEnableMaintenanceMode of
|
Clean `AppEnv` and `AppContext` passing, remove `RunT`, reduce `ServerConfigCtx` uses
## Description
This PR does several different things that happen to overlap; the most important being:
- it removes `RunT`: it was redundant in places where we already had `Handler`, and only used in one other place, `SchemaUpdate`, for which a local `SchemaUpdateT` is more than enough;
- it reduces the number of places where we create a `ServerConfigCtx`, since now `HasServerConfigCtx` can be implemented directly by `SchemaUpdateT` and `Handler` based on the full `AppContext`;
- it drastically reduces the number of arguments we pass around in the app init code, by introducing `HasAppEnv`;
- it simplifies `HandlerCtx` to reduce duplication
In doing so, this changes paves the way towards removing `ServerConfigCtx`, since there are only very few places where we construct it: we can now introduce smaller classes than `HasServerConfigCtx`, that expose only a relevant subset of fields, and implement them where we now implement `HasServerConfigCtx`.
This PR is loosely based on ideas in #8337, that are no longer applicable due to the changes introduced in #8159. A challenge of this PR was the postgres tests, which were running in `PGMetadataStorageAppT CacheBuild` :scream_cat:
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8392
GitOrigin-RevId: b90c1359066d20dbea329c87762ccdd1217b4d69
2023-03-21 13:44:21 +03:00
|
|
|
MaintenanceModeDisabled -> do
|
|
|
|
-- set modified metadata in storage
|
|
|
|
newResourceVersion <- liftEitherM $ setMetadata currentResourceVersion updatedMetadata
|
2023-06-26 13:55:11 +03:00
|
|
|
|
|
|
|
(_, modSchemaCache', _, _, _) <-
|
|
|
|
Tracing.newSpan "setMetadataResourceVersionInSchemaCache"
|
|
|
|
$ setMetadataResourceVersionInSchemaCache newResourceVersion
|
|
|
|
& runCacheRWT dynamicConfig modSchemaCache
|
|
|
|
|
2023-06-06 11:49:53 +03:00
|
|
|
-- save sources introspection to stored-introspection DB
|
|
|
|
saveSourcesIntrospection logger sourcesIntrospection newResourceVersion
|
2023-06-26 13:55:11 +03:00
|
|
|
-- run schema registry action
|
|
|
|
for_ schemaRegistryAction $ \action -> do
|
2023-06-26 21:19:06 +03:00
|
|
|
liftIO $ action newResourceVersion (scInconsistentObjs (lastBuiltSchemaCache modSchemaCache'))
|
Clean `AppEnv` and `AppContext` passing, remove `RunT`, reduce `ServerConfigCtx` uses
## Description
This PR does several different things that happen to overlap; the most important being:
- it removes `RunT`: it was redundant in places where we already had `Handler`, and only used in one other place, `SchemaUpdate`, for which a local `SchemaUpdateT` is more than enough;
- it reduces the number of places where we create a `ServerConfigCtx`, since now `HasServerConfigCtx` can be implemented directly by `SchemaUpdateT` and `Handler` based on the full `AppContext`;
- it drastically reduces the number of arguments we pass around in the app init code, by introducing `HasAppEnv`;
- it simplifies `HandlerCtx` to reduce duplication
In doing so, this changes paves the way towards removing `ServerConfigCtx`, since there are only very few places where we construct it: we can now introduce smaller classes than `HasServerConfigCtx`, that expose only a relevant subset of fields, and implement them where we now implement `HasServerConfigCtx`.
This PR is loosely based on ideas in #8337, that are no longer applicable due to the changes introduced in #8159. A challenge of this PR was the postgres tests, which were running in `PGMetadataStorageAppT CacheBuild` :scream_cat:
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8392
GitOrigin-RevId: b90c1359066d20dbea329c87762ccdd1217b4d69
2023-03-21 13:44:21 +03:00
|
|
|
-- notify schema cache sync
|
|
|
|
liftEitherM $ notifySchemaCacheSync newResourceVersion appEnvInstanceId invalidations
|
2023-06-26 13:55:11 +03:00
|
|
|
|
|
|
|
pure (result, modSchemaCache')
|
Clean `AppEnv` and `AppContext` passing, remove `RunT`, reduce `ServerConfigCtx` uses
## Description
This PR does several different things that happen to overlap; the most important being:
- it removes `RunT`: it was redundant in places where we already had `Handler`, and only used in one other place, `SchemaUpdate`, for which a local `SchemaUpdateT` is more than enough;
- it reduces the number of places where we create a `ServerConfigCtx`, since now `HasServerConfigCtx` can be implemented directly by `SchemaUpdateT` and `Handler` based on the full `AppContext`;
- it drastically reduces the number of arguments we pass around in the app init code, by introducing `HasAppEnv`;
- it simplifies `HandlerCtx` to reduce duplication
In doing so, this changes paves the way towards removing `ServerConfigCtx`, since there are only very few places where we construct it: we can now introduce smaller classes than `HasServerConfigCtx`, that expose only a relevant subset of fields, and implement them where we now implement `HasServerConfigCtx`.
This PR is loosely based on ideas in #8337, that are no longer applicable due to the changes introduced in #8159. A challenge of this PR was the postgres tests, which were running in `PGMetadataStorageAppT CacheBuild` :scream_cat:
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8392
GitOrigin-RevId: b90c1359066d20dbea329c87762ccdd1217b4d69
2023-03-21 13:44:21 +03:00
|
|
|
MaintenanceModeEnabled () ->
|
|
|
|
throw500 "metadata cannot be modified in maintenance mode"
|
2023-06-26 13:55:11 +03:00
|
|
|
else pure (result, modSchemaCache)
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2020-01-09 02:19:02 +03:00
|
|
|
-- | A predicate that determines whether the given query might modify/rebuild the schema cache. If
|
|
|
|
-- so, it needs to acquire the global lock on the schema cache so that other queries do not modify
|
|
|
|
-- it concurrently.
|
|
|
|
--
|
|
|
|
-- Ideally, we would enforce this using the type system — queries for which this function returns
|
|
|
|
-- 'False' should not be allowed to modify the schema cache. But for now we just ensure consistency
|
|
|
|
-- by hand.
|
|
|
|
queryModifiesSchemaCache :: RQLQuery -> Bool
|
|
|
|
queryModifiesSchemaCache (RQV1 qi) = case qi of
|
2020-07-14 22:00:58 +03:00
|
|
|
RQAddExistingTableOrView _ -> True
|
|
|
|
RQTrackTable _ -> True
|
|
|
|
RQUntrackTable _ -> True
|
|
|
|
RQTrackFunction _ -> True
|
|
|
|
RQUntrackFunction _ -> True
|
|
|
|
RQSetTableIsEnum _ -> True
|
|
|
|
RQCreateObjectRelationship _ -> True
|
|
|
|
RQCreateArrayRelationship _ -> True
|
|
|
|
RQDropRelationship _ -> True
|
|
|
|
RQSetRelationshipComment _ -> False
|
|
|
|
RQRenameRelationship _ -> True
|
|
|
|
RQAddComputedField _ -> True
|
|
|
|
RQDropComputedField _ -> True
|
|
|
|
RQCreateRemoteRelationship _ -> True
|
|
|
|
RQUpdateRemoteRelationship _ -> True
|
|
|
|
RQDeleteRemoteRelationship _ -> True
|
|
|
|
RQCreateInsertPermission _ -> True
|
|
|
|
RQCreateSelectPermission _ -> True
|
|
|
|
RQCreateUpdatePermission _ -> True
|
|
|
|
RQCreateDeletePermission _ -> True
|
|
|
|
RQDropInsertPermission _ -> True
|
|
|
|
RQDropSelectPermission _ -> True
|
|
|
|
RQDropUpdatePermission _ -> True
|
|
|
|
RQDropDeletePermission _ -> True
|
|
|
|
RQSetPermissionComment _ -> False
|
|
|
|
RQGetInconsistentMetadata _ -> False
|
|
|
|
RQDropInconsistentMetadata _ -> True
|
|
|
|
RQInsert _ -> False
|
|
|
|
RQSelect _ -> False
|
|
|
|
RQUpdate _ -> False
|
|
|
|
RQDelete _ -> False
|
|
|
|
RQCount _ -> False
|
|
|
|
RQAddRemoteSchema _ -> True
|
2021-06-21 20:41:43 +03:00
|
|
|
RQUpdateRemoteSchema _ -> True
|
2020-07-14 22:00:58 +03:00
|
|
|
RQRemoveRemoteSchema _ -> True
|
|
|
|
RQReloadRemoteSchema _ -> True
|
|
|
|
RQIntrospectRemoteSchema _ -> False
|
|
|
|
RQCreateEventTrigger _ -> True
|
|
|
|
RQDeleteEventTrigger _ -> True
|
|
|
|
RQRedeliverEvent _ -> False
|
|
|
|
RQInvokeEventTrigger _ -> False
|
|
|
|
RQCreateCronTrigger _ -> True
|
|
|
|
RQDeleteCronTrigger _ -> True
|
|
|
|
RQCreateScheduledEvent _ -> False
|
|
|
|
RQCreateQueryCollection _ -> True
|
2022-08-19 16:36:02 +03:00
|
|
|
RQRenameQueryCollection _ -> True
|
2020-07-14 22:00:58 +03:00
|
|
|
RQDropQueryCollection _ -> True
|
|
|
|
RQAddQueryToCollection _ -> True
|
|
|
|
RQDropQueryFromCollection _ -> True
|
|
|
|
RQAddCollectionToAllowlist _ -> True
|
|
|
|
RQDropCollectionFromAllowlist _ -> True
|
|
|
|
RQRunSql q -> isSchemaCacheBuildRequiredRunSQL q
|
|
|
|
RQReplaceMetadata _ -> True
|
|
|
|
RQExportMetadata _ -> False
|
|
|
|
RQClearMetadata _ -> True
|
|
|
|
RQReloadMetadata _ -> True
|
2021-01-29 04:02:34 +03:00
|
|
|
RQCreateRestEndpoint _ -> True
|
|
|
|
RQDropRestEndpoint _ -> True
|
2020-07-14 22:00:58 +03:00
|
|
|
RQCreateAction _ -> True
|
|
|
|
RQDropAction _ -> True
|
|
|
|
RQUpdateAction _ -> True
|
|
|
|
RQCreateActionPermission _ -> True
|
|
|
|
RQDropActionPermission _ -> True
|
|
|
|
RQDumpInternalState _ -> False
|
|
|
|
RQSetCustomTypes _ -> True
|
2020-10-29 15:48:45 +03:00
|
|
|
RQSetTableCustomization _ -> True
|
2020-07-14 22:00:58 +03:00
|
|
|
RQBulk qs -> any queryModifiesSchemaCache qs
|
2020-01-09 02:19:02 +03:00
|
|
|
queryModifiesSchemaCache (RQV2 qi) = case qi of
|
2019-09-19 07:47:36 +03:00
|
|
|
RQV2TrackTable _ -> True
|
|
|
|
RQV2SetTableCustomFields _ -> True
|
2019-11-20 09:47:06 +03:00
|
|
|
RQV2TrackFunction _ -> True
|
2021-02-16 11:08:19 +03:00
|
|
|
RQV2ReplaceMetadata _ -> True
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2021-12-08 09:26:46 +03:00
|
|
|
-- | A predicate that determines whether the given query might modify user's Database. If
|
|
|
|
-- so, when the server is run in safe mode, we should not proceed with those operations.
|
|
|
|
queryModifiesUserDB :: RQLQuery -> Bool
|
|
|
|
queryModifiesUserDB (RQV1 qi) = case qi of
|
|
|
|
RQAddExistingTableOrView _ -> False
|
|
|
|
RQTrackTable _ -> False
|
|
|
|
RQUntrackTable _ -> False
|
|
|
|
RQTrackFunction _ -> False
|
|
|
|
RQUntrackFunction _ -> False
|
|
|
|
RQSetTableIsEnum _ -> False
|
|
|
|
RQCreateObjectRelationship _ -> False
|
|
|
|
RQCreateArrayRelationship _ -> False
|
|
|
|
RQDropRelationship _ -> False
|
|
|
|
RQSetRelationshipComment _ -> False
|
|
|
|
RQRenameRelationship _ -> False
|
|
|
|
RQAddComputedField _ -> False
|
|
|
|
RQDropComputedField _ -> False
|
|
|
|
RQCreateRemoteRelationship _ -> False
|
|
|
|
RQUpdateRemoteRelationship _ -> False
|
|
|
|
RQDeleteRemoteRelationship _ -> False
|
|
|
|
RQCreateInsertPermission _ -> False
|
|
|
|
RQCreateSelectPermission _ -> False
|
|
|
|
RQCreateUpdatePermission _ -> False
|
|
|
|
RQCreateDeletePermission _ -> False
|
|
|
|
RQDropInsertPermission _ -> False
|
|
|
|
RQDropSelectPermission _ -> False
|
|
|
|
RQDropUpdatePermission _ -> False
|
|
|
|
RQDropDeletePermission _ -> False
|
|
|
|
RQSetPermissionComment _ -> False
|
|
|
|
RQGetInconsistentMetadata _ -> False
|
|
|
|
RQDropInconsistentMetadata _ -> False
|
|
|
|
RQInsert _ -> True
|
|
|
|
RQSelect _ -> False
|
|
|
|
RQUpdate _ -> True
|
|
|
|
RQDelete _ -> True
|
|
|
|
RQCount _ -> False
|
|
|
|
RQAddRemoteSchema _ -> False
|
|
|
|
RQUpdateRemoteSchema _ -> False
|
|
|
|
RQRemoveRemoteSchema _ -> False
|
|
|
|
RQReloadRemoteSchema _ -> False
|
|
|
|
RQIntrospectRemoteSchema _ -> False
|
|
|
|
RQCreateEventTrigger _ -> True
|
|
|
|
RQDeleteEventTrigger _ -> True
|
|
|
|
RQRedeliverEvent _ -> False
|
|
|
|
RQInvokeEventTrigger _ -> False
|
|
|
|
RQCreateCronTrigger _ -> False
|
|
|
|
RQDeleteCronTrigger _ -> False
|
|
|
|
RQCreateScheduledEvent _ -> False
|
|
|
|
RQCreateQueryCollection _ -> False
|
2022-08-19 16:36:02 +03:00
|
|
|
RQRenameQueryCollection _ -> False
|
2021-12-08 09:26:46 +03:00
|
|
|
RQDropQueryCollection _ -> False
|
|
|
|
RQAddQueryToCollection _ -> False
|
|
|
|
RQDropQueryFromCollection _ -> False
|
|
|
|
RQAddCollectionToAllowlist _ -> False
|
|
|
|
RQDropCollectionFromAllowlist _ -> False
|
|
|
|
RQRunSql _ -> True
|
|
|
|
RQReplaceMetadata _ -> True
|
|
|
|
RQExportMetadata _ -> False
|
|
|
|
RQClearMetadata _ -> False
|
|
|
|
RQReloadMetadata _ -> False
|
|
|
|
RQCreateRestEndpoint _ -> False
|
|
|
|
RQDropRestEndpoint _ -> False
|
|
|
|
RQCreateAction _ -> False
|
|
|
|
RQDropAction _ -> False
|
|
|
|
RQUpdateAction _ -> False
|
|
|
|
RQCreateActionPermission _ -> False
|
|
|
|
RQDropActionPermission _ -> False
|
|
|
|
RQDumpInternalState _ -> False
|
|
|
|
RQSetCustomTypes _ -> False
|
|
|
|
RQSetTableCustomization _ -> False
|
|
|
|
RQBulk qs -> any queryModifiesUserDB qs
|
|
|
|
queryModifiesUserDB (RQV2 qi) = case qi of
|
|
|
|
RQV2TrackTable _ -> False
|
|
|
|
RQV2SetTableCustomFields _ -> False
|
|
|
|
RQV2TrackFunction _ -> False
|
|
|
|
RQV2ReplaceMetadata _ -> True
|
|
|
|
|
2018-12-13 10:26:15 +03:00
|
|
|
runQueryM ::
|
2021-10-13 19:38:56 +03:00
|
|
|
( CacheRWM m,
|
2020-12-28 15:56:00 +03:00
|
|
|
UserInfoM m,
|
|
|
|
MonadBaseControl IO m,
|
|
|
|
MonadIO m,
|
2020-07-15 13:40:48 +03:00
|
|
|
Tracing.MonadTrace m,
|
2020-12-08 17:22:31 +03:00
|
|
|
MetadataM m,
|
2023-04-03 16:35:15 +03:00
|
|
|
MonadMetadataStorage m,
|
2021-07-29 11:29:12 +03:00
|
|
|
MonadQueryTags m,
|
2021-09-09 14:54:19 +03:00
|
|
|
MonadReader r m,
|
2023-02-03 04:03:23 +03:00
|
|
|
MonadError QErr m,
|
2022-09-15 14:45:14 +03:00
|
|
|
Has (L.Logger L.Hasura) r,
|
harmonize network manager handling
## Description
### I want to speak to the `Manager`
Oh boy. This PR is both fairly straightforward and overreaching, so let's break it down.
For most network access, we need a [`HTTP.Manager`](https://hackage.haskell.org/package/http-client-0.1.0.0/docs/Network-HTTP-Client-Manager.html). It is created only once, at the top level, when starting the engine, and is then threaded through the application to wherever we need to make a network call. As of main, the way we do this is not standardized: most of the GraphQL execution code passes it "manually" as a function argument throughout the code. We also have a custom monad constraint, `HasHttpManagerM`, that describes a monad's ability to provide a manager. And, finally, several parts of the code store the manager in some kind of argument structure, such as `RunT`'s `RunCtx`.
This PR's first goal is to harmonize all of this: we always create the manager at the root, and we already have it when we do our very first `runReaderT`. Wouldn't it make sense for the rest of the code to not manually pass it anywhere, to not store it anywhere, but to always rely on the current monad providing it? This is, in short, what this PR does: it implements a constraint on the base monads, so that they provide the manager, and removes most explicit passing from the code.
### First come, first served
One way this PR goes a tiny bit further than "just" doing the aforementioned harmonization is that it starts the process of implementing the "Services oriented architecture" roughly outlined in this [draft document](https://docs.google.com/document/d/1FAigqrST0juU1WcT4HIxJxe1iEBwTuBZodTaeUvsKqQ/edit?usp=sharing). Instead of using the existing `HasHTTPManagerM`, this PR revamps it into the `ProvidesNetwork` service.
The idea is, again, that we should make all "external" dependencies of the engine, all things that the core of the engine doesn't care about, a "service". This allows us to define clear APIs for features, to choose different implementations based on which version of the engine we're running, harmonizes our many scattered monadic constraints... Which is why this service is called "Network": we can refine it, moving forward, to be the constraint that defines how all network communication is to operate, instead of relying on disparate classes constraint or hardcoded decisions. A comment in the code clarifies this intent.
### Side-effects? In my Haskell?
This PR also unavoidably touches some other aspects of the codebase. One such example: it introduces `Hasura.App.AppContext`, named after `HasuraPro.Context.AppContext`: a name for the reader structure at the base level. It also transforms `Handler` from a type alias to a newtype, as `Handler` is where we actually enforce HTTP limits; but without `Handler` being a distinct type, any code path could simply do a `runExceptT $ runReader` and forget to enforce them.
(As a rule of thumb, i am starting to consider any straggling `runReaderT` or `runExceptT` as a code smell: we should not stack / unstack monads haphazardly, and every layer should be an opaque `newtype` with a corresponding run function.)
## Further work
In several places, i have left TODOs when i have encountered things that suggest that we should do further unrelated cleanups. I'll write down the follow-up steps, either in the aforementioned document or on slack. But, in short, at a glance, in approximate order, we could:
- delete `ExecutionCtx` as it is only a subset of `ServerCtx`, and remove one more `runReaderT` call
- delete `ServerConfigCtx` as it is only a subset of `ServerCtx`, and remove it from `RunCtx`
- remove `ServerCtx` from `HandlerCtx`, and make it part of `AppContext`, or even make it the `AppContext` altogether (since, at least for the OSS version, `AppContext` is there again only a subset)
- remove `CacheBuildParams` and `CacheBuild` altogether, as they're just a distinct stack that is a `ReaderT` on top of `IO` that contains, you guessed it, the same thing as `ServerCtx`
- move `RunT` out of `RQL.Types` and rename it, since after the previous cleanups **it only contains `UserInfo`**; it could be bundled with the authentication service, made a small implementation detail in `Hasura.Server.Auth`
- rename `PGMetadaStorageT` to something a bit more accurate, such as `App`, and enforce its IO base
This would significantly simply our complex stack. From there, or in parallel, we can start moving existing dependencies as Services. For the purpose of supporting read replicas entitlement, we could move `MonadResolveSource` to a `SourceResolver` service, as attempted in #7653, and transform `UserAuthenticationM` into a `Authentication` service.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7736
GitOrigin-RevId: 68cce710eb9e7d752bda1ba0c49541d24df8209f
2023-02-22 18:53:52 +03:00
|
|
|
MonadEventLogCleanup m,
|
2023-03-13 14:44:18 +03:00
|
|
|
ProvidesHasuraServices m,
|
2023-05-11 08:19:42 +03:00
|
|
|
MonadGetPolicies m
|
2020-07-14 22:00:58 +03:00
|
|
|
) =>
|
|
|
|
Env.Environment ->
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
SQLGenCtx ->
|
2020-07-14 22:00:58 +03:00
|
|
|
RQLQuery ->
|
2019-03-18 19:22:21 +03:00
|
|
|
m EncJSON
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
runQueryM env sqlGen rq = withPathK "args" $ case rq of
|
2020-01-09 02:19:02 +03:00
|
|
|
RQV1 q -> runQueryV1M q
|
|
|
|
RQV2 q -> runQueryV2M q
|
2019-07-08 08:51:41 +03:00
|
|
|
where
|
2019-09-19 07:47:36 +03:00
|
|
|
runQueryV1M = \case
|
2020-11-02 14:50:40 +03:00
|
|
|
RQAddExistingTableOrView q -> runTrackTableQ q
|
|
|
|
RQTrackTable q -> runTrackTableQ q
|
|
|
|
RQUntrackTable q -> runUntrackTableQ q
|
|
|
|
RQSetTableIsEnum q -> runSetExistingTableIsEnumQ q
|
2021-01-08 10:41:50 +03:00
|
|
|
RQSetTableCustomization q -> runSetTableCustomization q
|
2023-04-03 13:18:54 +03:00
|
|
|
RQTrackFunction q -> Functions.runTrackFunc q
|
|
|
|
RQUntrackFunction q -> Functions.runUntrackFunc q
|
2021-07-07 04:43:42 +03:00
|
|
|
RQCreateObjectRelationship q -> runCreateRelationship ObjRel $ unCreateObjRel q
|
|
|
|
RQCreateArrayRelationship q -> runCreateRelationship ArrRel $ unCreateArrRel q
|
2020-11-02 14:50:40 +03:00
|
|
|
RQDropRelationship q -> runDropRel q
|
|
|
|
RQSetRelationshipComment q -> runSetRelComment q
|
|
|
|
RQRenameRelationship q -> runRenameRel q
|
|
|
|
RQAddComputedField q -> runAddComputedField q
|
|
|
|
RQDropComputedField q -> runDropComputedField q
|
|
|
|
RQCreateInsertPermission q -> runCreatePerm q
|
|
|
|
RQCreateSelectPermission q -> runCreatePerm q
|
|
|
|
RQCreateUpdatePermission q -> runCreatePerm q
|
|
|
|
RQCreateDeletePermission q -> runCreatePerm q
|
2022-04-06 15:47:35 +03:00
|
|
|
RQDropInsertPermission q -> runDropPerm PTInsert q
|
|
|
|
RQDropSelectPermission q -> runDropPerm PTSelect q
|
|
|
|
RQDropUpdatePermission q -> runDropPerm PTUpdate q
|
|
|
|
RQDropDeletePermission q -> runDropPerm PTDelete q
|
2020-11-02 14:50:40 +03:00
|
|
|
RQSetPermissionComment q -> runSetPermComment q
|
|
|
|
RQGetInconsistentMetadata q -> runGetInconsistentMetadata q
|
|
|
|
RQDropInconsistentMetadata q -> runDropInconsistentMetadata q
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
RQInsert q -> runInsert sqlGen q
|
|
|
|
RQSelect q -> runSelect sqlGen q
|
|
|
|
RQUpdate q -> runUpdate sqlGen q
|
|
|
|
RQDelete q -> runDelete sqlGen q
|
2021-01-07 12:04:22 +03:00
|
|
|
RQCount q -> runCount q
|
2020-11-02 14:50:40 +03:00
|
|
|
RQAddRemoteSchema q -> runAddRemoteSchema env q
|
2021-06-21 20:41:43 +03:00
|
|
|
RQUpdateRemoteSchema q -> runUpdateRemoteSchema env q
|
2020-11-02 14:50:40 +03:00
|
|
|
RQRemoveRemoteSchema q -> runRemoveRemoteSchema q
|
|
|
|
RQReloadRemoteSchema q -> runReloadRemoteSchema q
|
|
|
|
RQIntrospectRemoteSchema q -> runIntrospectRemoteSchema q
|
Fix several issues with remote relationships.
## Remaining Work
- [x] changelog entry
- [x] more tests: `<backend>_delete_remote_relationship` is definitely untested
- [x] negative tests: we probably want to assert that there are some APIs we DON'T support
- [x] update the console to use the new API, if necessary
- [x] ~~adding the corresponding documentation for the API for other backends (only `pg_` was added here)~~
- deferred to https://github.com/hasura/graphql-engine-mono/issues/3170
- [x] ~~deciding which backends should support this API~~
- deferred to https://github.com/hasura/graphql-engine-mono/issues/3170
- [x] ~~deciding what to do about potentially overlapping schematic representations~~
- ~~cf. https://github.com/hasura/graphql-engine-mono/pull/3157#issuecomment-995307624~~
- deferred to https://github.com/hasura/graphql-engine-mono/issues/3171
- [x] ~~add more descriptive versioning information to some of the types that are changing in this PR~~
- cf. https://github.com/hasura/graphql-engine-mono/pull/3157#discussion_r769830920
- deferred to https://github.com/hasura/graphql-engine-mono/issues/3172
## Description
This PR fixes several important issues wrt. the remote relationship API.
- it fixes a regression introduced by [#3124](https://github.com/hasura/graphql-engine-mono/pull/3124), which prevented `<backend>_create_remote_relationship` from accepting the old argument format (break of backwards compatibility, broke the console)
- it removes the command `create_remote_relationship` added to the v1/metadata API as a work-around as part of [#3124](https://github.com/hasura/graphql-engine-mono/pull/3124)
- it reverts the subsequent fix in the console: [#3149](https://github.com/hasura/graphql-engine-mono/pull/3149)
Furthermore, this PR also addresses two other issues:
- THE DOCUMENTATION OF THE METADATA API WAS WRONG, and documented `create_remote_relationship` instead of `<backend>_create_remote_relationship`: this PR fixes this by adding `pg_` everywhere, but does not attempt to add the corresponding documentation for other backends, partly because:
- `<backend>_delete_remote_relationship` WAS BROKEN ON NON-POSTGRES BACKENDS; it always expected an argument parameterized by Postgres.
As of main, the `<backend>_(create|update|delete)_remote_relationship` commands are supported on Postgres, Citus, BigQuery, but **NOT MSSQL**. I do not know if this is intentional or not, if it even should be publicized or not, and as a result this PR doesn't change this.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3157
Co-authored-by: jkachmar <8461423+jkachmar@users.noreply.github.com>
GitOrigin-RevId: 37e2f41522a9229a11c595574c3f4984317d652a
2021-12-16 23:28:08 +03:00
|
|
|
RQCreateRemoteRelationship q -> runCreateRemoteRelationship q
|
|
|
|
RQUpdateRemoteRelationship q -> runUpdateRemoteRelationship q
|
2020-11-02 14:50:40 +03:00
|
|
|
RQDeleteRemoteRelationship q -> runDeleteRemoteRelationship q
|
|
|
|
RQCreateEventTrigger q -> runCreateEventTriggerQuery q
|
|
|
|
RQDeleteEventTrigger q -> runDeleteEventTriggerQuery q
|
|
|
|
RQRedeliverEvent q -> runRedeliverEvent q
|
|
|
|
RQInvokeEventTrigger q -> runInvokeEventTrigger q
|
|
|
|
RQCreateCronTrigger q -> runCreateCronTrigger q
|
|
|
|
RQDeleteCronTrigger q -> runDeleteCronTrigger q
|
|
|
|
RQCreateScheduledEvent q -> runCreateScheduledEvent q
|
|
|
|
RQCreateQueryCollection q -> runCreateCollection q
|
2022-08-19 16:36:02 +03:00
|
|
|
RQRenameQueryCollection q -> runRenameCollection q
|
2020-11-02 14:50:40 +03:00
|
|
|
RQDropQueryCollection q -> runDropCollection q
|
|
|
|
RQAddQueryToCollection q -> runAddQueryToCollection q
|
|
|
|
RQDropQueryFromCollection q -> runDropQueryFromCollection q
|
|
|
|
RQAddCollectionToAllowlist q -> runAddCollectionToAllowlist q
|
|
|
|
RQDropCollectionFromAllowlist q -> runDropCollectionFromAllowlist q
|
|
|
|
RQReplaceMetadata q -> runReplaceMetadata q
|
|
|
|
RQClearMetadata q -> runClearMetadata q
|
|
|
|
RQExportMetadata q -> runExportMetadata q
|
|
|
|
RQReloadMetadata q -> runReloadMetadata q
|
|
|
|
RQCreateAction q -> runCreateAction q
|
|
|
|
RQDropAction q -> runDropAction q
|
|
|
|
RQUpdateAction q -> runUpdateAction q
|
|
|
|
RQCreateActionPermission q -> runCreateActionPermission q
|
|
|
|
RQDropActionPermission q -> runDropActionPermission q
|
2021-01-29 04:02:34 +03:00
|
|
|
RQCreateRestEndpoint q -> runCreateEndpoint q
|
|
|
|
RQDropRestEndpoint q -> runDropEndpoint q
|
2020-11-02 14:50:40 +03:00
|
|
|
RQDumpInternalState q -> runDumpInternalState q
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
RQRunSql q -> runRunSQL @'Vanilla sqlGen q
|
2020-11-02 14:50:40 +03:00
|
|
|
RQSetCustomTypes q -> runSetCustomTypes q
|
Remove `ServerConfigCtx`.
### Description
This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively
The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).
The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.
(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 18:59:58 +03:00
|
|
|
RQBulk qs -> encJFromList <$> indexedMapM (runQueryM env sqlGen) qs
|
2019-09-19 07:47:36 +03:00
|
|
|
|
|
|
|
runQueryV2M = \case
|
2021-01-29 04:02:34 +03:00
|
|
|
RQV2TrackTable q -> runTrackTableV2Q q
|
|
|
|
RQV2SetTableCustomFields q -> runSetTableCustomFieldsQV2 q
|
2023-04-03 13:18:54 +03:00
|
|
|
RQV2TrackFunction q -> Functions.runTrackFunctionV2 q
|
2022-12-16 13:19:42 +03:00
|
|
|
RQV2ReplaceMetadata q -> runReplaceMetadataV2 q
|
2019-11-26 15:14:21 +03:00
|
|
|
|
|
|
|
requiresAdmin :: RQLQuery -> Bool
|
|
|
|
requiresAdmin = \case
|
|
|
|
RQV1 q -> case q of
|
2020-07-14 22:00:58 +03:00
|
|
|
RQAddExistingTableOrView _ -> True
|
|
|
|
RQTrackTable _ -> True
|
|
|
|
RQUntrackTable _ -> True
|
|
|
|
RQSetTableIsEnum _ -> True
|
2021-01-08 10:41:50 +03:00
|
|
|
RQSetTableCustomization _ -> True
|
2020-07-14 22:00:58 +03:00
|
|
|
RQTrackFunction _ -> True
|
|
|
|
RQUntrackFunction _ -> True
|
|
|
|
RQCreateObjectRelationship _ -> True
|
|
|
|
RQCreateArrayRelationship _ -> True
|
|
|
|
RQDropRelationship _ -> True
|
|
|
|
RQSetRelationshipComment _ -> True
|
|
|
|
RQRenameRelationship _ -> True
|
|
|
|
RQAddComputedField _ -> True
|
|
|
|
RQDropComputedField _ -> True
|
|
|
|
RQCreateRemoteRelationship _ -> True
|
|
|
|
RQUpdateRemoteRelationship _ -> True
|
|
|
|
RQDeleteRemoteRelationship _ -> True
|
|
|
|
RQCreateInsertPermission _ -> True
|
|
|
|
RQCreateSelectPermission _ -> True
|
|
|
|
RQCreateUpdatePermission _ -> True
|
|
|
|
RQCreateDeletePermission _ -> True
|
|
|
|
RQDropInsertPermission _ -> True
|
|
|
|
RQDropSelectPermission _ -> True
|
|
|
|
RQDropUpdatePermission _ -> True
|
|
|
|
RQDropDeletePermission _ -> True
|
|
|
|
RQSetPermissionComment _ -> True
|
|
|
|
RQGetInconsistentMetadata _ -> True
|
|
|
|
RQDropInconsistentMetadata _ -> True
|
|
|
|
RQInsert _ -> False
|
|
|
|
RQSelect _ -> False
|
|
|
|
RQUpdate _ -> False
|
|
|
|
RQDelete _ -> False
|
|
|
|
RQCount _ -> False
|
|
|
|
RQAddRemoteSchema _ -> True
|
2021-06-21 20:41:43 +03:00
|
|
|
RQUpdateRemoteSchema _ -> True
|
2020-07-14 22:00:58 +03:00
|
|
|
RQRemoveRemoteSchema _ -> True
|
|
|
|
RQReloadRemoteSchema _ -> True
|
|
|
|
RQIntrospectRemoteSchema _ -> True
|
|
|
|
RQCreateEventTrigger _ -> True
|
|
|
|
RQDeleteEventTrigger _ -> True
|
|
|
|
RQRedeliverEvent _ -> True
|
|
|
|
RQInvokeEventTrigger _ -> True
|
|
|
|
RQCreateCronTrigger _ -> True
|
|
|
|
RQDeleteCronTrigger _ -> True
|
|
|
|
RQCreateScheduledEvent _ -> True
|
|
|
|
RQCreateQueryCollection _ -> True
|
2022-08-19 16:36:02 +03:00
|
|
|
RQRenameQueryCollection _ -> True
|
2020-07-14 22:00:58 +03:00
|
|
|
RQDropQueryCollection _ -> True
|
|
|
|
RQAddQueryToCollection _ -> True
|
|
|
|
RQDropQueryFromCollection _ -> True
|
|
|
|
RQAddCollectionToAllowlist _ -> True
|
|
|
|
RQDropCollectionFromAllowlist _ -> True
|
|
|
|
RQReplaceMetadata _ -> True
|
|
|
|
RQClearMetadata _ -> True
|
|
|
|
RQExportMetadata _ -> True
|
|
|
|
RQReloadMetadata _ -> True
|
2021-01-29 04:02:34 +03:00
|
|
|
RQCreateRestEndpoint _ -> True
|
|
|
|
RQDropRestEndpoint _ -> True
|
2020-07-14 22:00:58 +03:00
|
|
|
RQCreateAction _ -> True
|
|
|
|
RQDropAction _ -> True
|
|
|
|
RQUpdateAction _ -> True
|
|
|
|
RQCreateActionPermission _ -> True
|
|
|
|
RQDropActionPermission _ -> True
|
|
|
|
RQDumpInternalState _ -> True
|
|
|
|
RQSetCustomTypes _ -> True
|
|
|
|
RQRunSql _ -> True
|
|
|
|
RQBulk qs -> any requiresAdmin qs
|
2019-11-26 15:14:21 +03:00
|
|
|
RQV2 q -> case q of
|
|
|
|
RQV2TrackTable _ -> True
|
|
|
|
RQV2SetTableCustomFields _ -> True
|
|
|
|
RQV2TrackFunction _ -> True
|
2021-02-16 11:08:19 +03:00
|
|
|
RQV2ReplaceMetadata _ -> True
|