2021-11-04 19:08:33 +03:00
|
|
|
module Hasura.Server.API.Metadata
|
|
|
|
( RQLMetadataV1 (..),
|
|
|
|
)
|
|
|
|
where
|
2021-07-07 04:43:42 +03:00
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.RQL.DDL.Action
|
|
|
|
import Hasura.RQL.DDL.ComputedField
|
|
|
|
import Hasura.RQL.DDL.EventTrigger
|
|
|
|
import Hasura.RQL.DDL.Metadata
|
|
|
|
import Hasura.RQL.DDL.Permission
|
|
|
|
import Hasura.RQL.DDL.QueryTags
|
|
|
|
import Hasura.RQL.DDL.Relationship
|
|
|
|
import Hasura.RQL.DDL.Relationship.Rename
|
|
|
|
import Hasura.RQL.DDL.RemoteRelationship
|
|
|
|
import Hasura.RQL.DDL.Schema
|
|
|
|
import Hasura.RQL.DDL.Schema.Source
|
2022-03-11 02:22:54 +03:00
|
|
|
import Hasura.RQL.DDL.Webhook.Transform.Validation
|
2022-04-27 16:57:28 +03:00
|
|
|
import Hasura.RQL.Types.Allowlist
|
|
|
|
import Hasura.RQL.Types.ApiLimit
|
|
|
|
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.GraphqlSchemaIntrospection
|
|
|
|
import Hasura.RQL.Types.Metadata
|
|
|
|
import Hasura.RQL.Types.Network
|
|
|
|
import Hasura.RQL.Types.QueryCollection
|
|
|
|
import Hasura.RQL.Types.RemoteSchema
|
|
|
|
import Hasura.RQL.Types.Roles
|
|
|
|
import Hasura.RQL.Types.ScheduledTrigger
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.SQL.AnyBackend
|
2021-07-07 04:43:42 +03:00
|
|
|
|
|
|
|
data RQLMetadataV1
|
2021-09-24 01:56:37 +03:00
|
|
|
= -- Sources
|
|
|
|
RMAddSource !(AnyBackend AddSource)
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMDropSource DropSource
|
|
|
|
| RMRenameSource !RenameSource
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Tables
|
|
|
|
RMTrackTable !(AnyBackend TrackTableV2)
|
|
|
|
| RMUntrackTable !(AnyBackend UntrackTable)
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMSetTableCustomization !(AnyBackend SetTableCustomization)
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Tables (PG-specific)
|
|
|
|
RMPgSetTableIsEnum !SetTableIsEnum
|
|
|
|
| -- Tables permissions
|
|
|
|
RMCreateInsertPermission !(AnyBackend (CreatePerm InsPerm))
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMCreateSelectPermission !(AnyBackend (CreatePerm SelPerm))
|
|
|
|
| RMCreateUpdatePermission !(AnyBackend (CreatePerm UpdPerm))
|
|
|
|
| RMCreateDeletePermission !(AnyBackend (CreatePerm DelPerm))
|
2022-04-06 15:47:35 +03:00
|
|
|
| RMDropInsertPermission !(AnyBackend DropPerm)
|
|
|
|
| RMDropSelectPermission !(AnyBackend DropPerm)
|
|
|
|
| RMDropUpdatePermission !(AnyBackend DropPerm)
|
|
|
|
| RMDropDeletePermission !(AnyBackend DropPerm)
|
2021-09-24 01:56:37 +03:00
|
|
|
| RMSetPermissionComment !(AnyBackend SetPermComment)
|
|
|
|
| -- Tables relationships
|
|
|
|
RMCreateObjectRelationship !(AnyBackend CreateObjRel)
|
|
|
|
| RMCreateArrayRelationship !(AnyBackend CreateArrRel)
|
|
|
|
| RMDropRelationship !(AnyBackend DropRel)
|
|
|
|
| RMSetRelationshipComment !(AnyBackend SetRelComment)
|
|
|
|
| RMRenameRelationship !(AnyBackend RenameRel)
|
|
|
|
| -- Tables remote relationships
|
2021-12-01 07:53:34 +03:00
|
|
|
RMCreateRemoteRelationship !(AnyBackend CreateFromSourceRelationship)
|
|
|
|
| RMUpdateRemoteRelationship !(AnyBackend CreateFromSourceRelationship)
|
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
|
|
|
| RMDeleteRemoteRelationship !(AnyBackend DeleteFromSourceRelationship)
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Functions
|
|
|
|
RMTrackFunction !(AnyBackend TrackFunctionV2)
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMUntrackFunction !(AnyBackend UnTrackFunction)
|
2021-10-07 16:02:19 +03:00
|
|
|
| RMSetFunctionCustomization (AnyBackend SetFunctionCustomization)
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Functions permissions
|
|
|
|
RMCreateFunctionPermission !(AnyBackend FunctionPermissionArgument)
|
|
|
|
| RMDropFunctionPermission !(AnyBackend FunctionPermissionArgument)
|
2022-05-04 17:52:29 +03:00
|
|
|
| -- Computed fields
|
|
|
|
RMAddComputedField !(AnyBackend AddComputedField)
|
|
|
|
| RMDropComputedField !(AnyBackend DropComputedField)
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Tables event triggers
|
2022-03-11 02:22:54 +03:00
|
|
|
RMCreateEventTrigger !(AnyBackend (Unvalidated1 CreateEventTriggerQuery))
|
2021-09-24 01:56:37 +03:00
|
|
|
| RMDeleteEventTrigger !(AnyBackend DeleteEventTriggerQuery)
|
|
|
|
| RMRedeliverEvent !(AnyBackend RedeliverEventQuery)
|
|
|
|
| RMInvokeEventTrigger !(AnyBackend InvokeEventTriggerQuery)
|
|
|
|
| -- Remote schemas
|
|
|
|
RMAddRemoteSchema !AddRemoteSchemaQuery
|
|
|
|
| RMUpdateRemoteSchema !AddRemoteSchemaQuery
|
|
|
|
| RMRemoveRemoteSchema !RemoteSchemaNameQuery
|
|
|
|
| RMReloadRemoteSchema !RemoteSchemaNameQuery
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMIntrospectRemoteSchema !RemoteSchemaNameQuery
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Remote schemas permissions
|
|
|
|
RMAddRemoteSchemaPermissions !AddRemoteSchemaPermission
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMDropRemoteSchemaPermissions !DropRemoteSchemaPermissions
|
2022-03-17 23:53:56 +03:00
|
|
|
| -- Remote Schema remote relationships
|
|
|
|
RMCreateRemoteSchemaRemoteRelationship CreateRemoteSchemaRemoteRelationship
|
|
|
|
| RMUpdateRemoteSchemaRemoteRelationship CreateRemoteSchemaRemoteRelationship
|
|
|
|
| RMDeleteRemoteSchemaRemoteRelationship DeleteRemoteSchemaRemoteRelationship
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Scheduled triggers
|
2022-03-11 02:22:54 +03:00
|
|
|
RMCreateCronTrigger !(Unvalidated CreateCronTrigger)
|
2021-09-24 01:56:37 +03:00
|
|
|
| RMDeleteCronTrigger !ScheduledTriggerName
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMCreateScheduledEvent !CreateScheduledEvent
|
|
|
|
| RMDeleteScheduledEvent !DeleteScheduledEvent
|
2021-09-24 01:56:37 +03:00
|
|
|
| RMGetScheduledEvents !GetScheduledEvents
|
|
|
|
| RMGetEventInvocations !GetEventInvocations
|
2022-01-27 09:43:39 +03:00
|
|
|
| RMGetCronTriggers
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Actions
|
2022-03-11 02:22:54 +03:00
|
|
|
RMCreateAction !(Unvalidated CreateAction)
|
2021-09-24 01:56:37 +03:00
|
|
|
| RMDropAction !DropAction
|
2022-03-11 02:22:54 +03:00
|
|
|
| RMUpdateAction !(Unvalidated UpdateAction)
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMCreateActionPermission !CreateActionPermission
|
2021-09-24 01:56:37 +03:00
|
|
|
| RMDropActionPermission !DropActionPermission
|
|
|
|
| -- Query collections, allow list related
|
|
|
|
RMCreateQueryCollection !CreateCollection
|
|
|
|
| RMDropQueryCollection !DropCollection
|
|
|
|
| RMAddQueryToCollection !AddQueryToCollection
|
|
|
|
| RMDropQueryFromCollection !DropQueryFromCollection
|
2022-02-08 19:53:30 +03:00
|
|
|
| RMAddCollectionToAllowlist !AllowlistEntry
|
|
|
|
| RMDropCollectionFromAllowlist !DropCollectionFromAllowlist
|
|
|
|
| RMUpdateScopeOfCollectionInAllowlist !UpdateScopeOfCollectionInAllowlist
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Rest endpoints
|
|
|
|
RMCreateRestEndpoint !CreateEndpoint
|
|
|
|
| RMDropRestEndpoint !DropEndpoint
|
|
|
|
| -- Custom types
|
|
|
|
RMSetCustomTypes !CustomTypes
|
|
|
|
| -- Api limits
|
|
|
|
RMSetApiLimits !ApiLimit
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMRemoveApiLimits
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Metrics config
|
|
|
|
RMSetMetricsConfig !MetricsConfig
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMRemoveMetricsConfig
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Inherited roles
|
|
|
|
RMAddInheritedRole !InheritedRole
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMDropInheritedRole !DropInheritedRole
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Metadata management
|
|
|
|
RMReplaceMetadata !ReplaceMetadata
|
|
|
|
| RMExportMetadata !ExportMetadata
|
|
|
|
| RMClearMetadata !ClearMetadata
|
|
|
|
| RMReloadMetadata !ReloadMetadata
|
|
|
|
| RMGetInconsistentMetadata !GetInconsistentMetadata
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMDropInconsistentMetadata !DropInconsistentMetadata
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Introspection options
|
|
|
|
RMSetGraphqlSchemaIntrospectionOptions !SetGraphqlIntrospectionOptions
|
|
|
|
| -- Network
|
|
|
|
RMAddHostToTLSAllowlist !AddHostToTLSAllowlist
|
2021-08-24 10:36:32 +03:00
|
|
|
| RMDropHostFromTLSAllowlist !DropHostFromTLSAllowlist
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- QueryTags
|
|
|
|
RMSetQueryTagsConfig !SetQueryTagsConfig
|
|
|
|
| -- Debug
|
|
|
|
RMDumpInternalState !DumpInternalState
|
|
|
|
| RMGetCatalogState !GetCatalogState
|
|
|
|
| RMSetCatalogState !SetCatalogState
|
2022-03-11 02:22:54 +03:00
|
|
|
| RMTestWebhookTransform !(Unvalidated TestWebhookTransform)
|
2021-09-24 01:56:37 +03:00
|
|
|
| -- Bulk metadata queries
|
|
|
|
RMBulk [RQLMetadataRequest]
|
2021-07-07 04:43:42 +03:00
|
|
|
|
|
|
|
data RQLMetadataV2
|
|
|
|
= RMV2ReplaceMetadata !ReplaceMetadataV2
|
2021-09-24 01:56:37 +03:00
|
|
|
| RMV2ExportMetadata !ExportMetadata
|
2021-07-07 04:43:42 +03:00
|
|
|
|
|
|
|
data RQLMetadataRequest
|
|
|
|
= RMV1 !RQLMetadataV1
|
|
|
|
| RMV2 !RQLMetadataV2
|