2021-07-07 04:43:42 +03:00
|
|
|
module Hasura.Server.API.Metadata where
|
|
|
|
|
|
|
|
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.QueryCollection
|
2021-09-23 15:37:56 +03:00
|
|
|
import Hasura.RQL.DDL.QueryTags
|
Clean metadata arguments
## Description
Thanks to #1664, the Metadata API types no longer require a `ToJSON` instance. This PR follows up with a cleanup of the types of the arguments to the metadata API:
- whenever possible, it moves those argument types to where they're used (RQL.DDL.*)
- it removes all unrequired instances (mostly `ToJSON`)
This PR does not attempt to do it for _all_ such argument types. For some of the metadata operations, the type used to describe the argument to the API and used to represent the value in the metadata are one and the same (like for `CreateEndpoint`). Sometimes, the two types are intertwined in complex ways (`RemoteRelationship` and `RemoteRelationshipDef`). In the spirit of only doing uncontroversial cleaning work, this PR only moves types that are not used outside of RQL.DDL.
Furthermore, this is a small step towards separating the different types all jumbled together in RQL.Types.
## Notes
This PR also improves several `FromJSON` instances to make use of `withObject`, and to use a human readable string instead of a type name in error messages whenever possible. For instance:
- before: `expected Object for Object, but encountered X`
after: `expected Object for add computed field, but encountered X`
- before: `Expecting an object for update query`
after: `expected Object for update query, but encountered X`
This PR also renames `CreateFunctionPermission` to `FunctionPermissionArgument`, to remove the quite surprising `type DropFunctionPermission = CreateFunctionPermission`.
This PR also deletes some dead code, mostly in RQL.DML.
This PR also moves a PG-specific source resolving function from DDL.Schema.Source to the only place where it is used: App.hs.
https://github.com/hasura/graphql-engine-mono/pull/1844
GitOrigin-RevId: a594521194bb7fe6a111b02a9e099896f9fed59c
2021-07-27 13:41:42 +03:00
|
|
|
import Hasura.RQL.DDL.Relationship
|
|
|
|
import Hasura.RQL.DDL.Relationship.Rename
|
|
|
|
import Hasura.RQL.DDL.RemoteRelationship
|
2021-07-07 04:43:42 +03:00
|
|
|
import Hasura.RQL.DDL.Schema
|
Clean metadata arguments
## Description
Thanks to #1664, the Metadata API types no longer require a `ToJSON` instance. This PR follows up with a cleanup of the types of the arguments to the metadata API:
- whenever possible, it moves those argument types to where they're used (RQL.DDL.*)
- it removes all unrequired instances (mostly `ToJSON`)
This PR does not attempt to do it for _all_ such argument types. For some of the metadata operations, the type used to describe the argument to the API and used to represent the value in the metadata are one and the same (like for `CreateEndpoint`). Sometimes, the two types are intertwined in complex ways (`RemoteRelationship` and `RemoteRelationshipDef`). In the spirit of only doing uncontroversial cleaning work, this PR only moves types that are not used outside of RQL.DDL.
Furthermore, this is a small step towards separating the different types all jumbled together in RQL.Types.
## Notes
This PR also improves several `FromJSON` instances to make use of `withObject`, and to use a human readable string instead of a type name in error messages whenever possible. For instance:
- before: `expected Object for Object, but encountered X`
after: `expected Object for add computed field, but encountered X`
- before: `Expecting an object for update query`
after: `expected Object for update query, but encountered X`
This PR also renames `CreateFunctionPermission` to `FunctionPermissionArgument`, to remove the quite surprising `type DropFunctionPermission = CreateFunctionPermission`.
This PR also deletes some dead code, mostly in RQL.DML.
This PR also moves a PG-specific source resolving function from DDL.Schema.Source to the only place where it is used: App.hs.
https://github.com/hasura/graphql-engine-mono/pull/1844
GitOrigin-RevId: a594521194bb7fe6a111b02a9e099896f9fed59c
2021-07-27 13:41:42 +03:00
|
|
|
import Hasura.RQL.DDL.Schema.Source
|
2021-07-07 04:43:42 +03:00
|
|
|
import Hasura.RQL.Types
|
|
|
|
import Hasura.SQL.AnyBackend
|
|
|
|
|
|
|
|
|
|
|
|
data RQLMetadataV1
|
|
|
|
-- Sources
|
|
|
|
= RMAddSource !(AnyBackend AddSource)
|
|
|
|
| RMDropSource DropSource
|
|
|
|
| RMRenameSource !RenameSource
|
|
|
|
|
|
|
|
-- Tables
|
|
|
|
| RMTrackTable !(AnyBackend TrackTableV2)
|
|
|
|
| RMUntrackTable !(AnyBackend UntrackTable)
|
|
|
|
| RMSetTableCustomization !(AnyBackend SetTableCustomization)
|
|
|
|
|
|
|
|
-- Tables (PG-specific)
|
|
|
|
| RMPgSetTableIsEnum !SetTableIsEnum
|
|
|
|
|
|
|
|
-- Tables permissions
|
|
|
|
| RMCreateInsertPermission !(AnyBackend (CreatePerm InsPerm))
|
|
|
|
| RMCreateSelectPermission !(AnyBackend (CreatePerm SelPerm))
|
|
|
|
| RMCreateUpdatePermission !(AnyBackend (CreatePerm UpdPerm))
|
|
|
|
| RMCreateDeletePermission !(AnyBackend (CreatePerm DelPerm))
|
|
|
|
| RMDropInsertPermission !(AnyBackend (DropPerm InsPerm))
|
|
|
|
| RMDropSelectPermission !(AnyBackend (DropPerm SelPerm))
|
|
|
|
| RMDropUpdatePermission !(AnyBackend (DropPerm UpdPerm))
|
|
|
|
| RMDropDeletePermission !(AnyBackend (DropPerm DelPerm))
|
|
|
|
| RMSetPermissionComment !(AnyBackend SetPermComment)
|
|
|
|
|
|
|
|
-- Tables relationships
|
|
|
|
| RMCreateObjectRelationship !(AnyBackend CreateObjRel)
|
|
|
|
| RMCreateArrayRelationship !(AnyBackend CreateArrRel)
|
|
|
|
| RMDropRelationship !(AnyBackend DropRel)
|
|
|
|
| RMSetRelationshipComment !(AnyBackend SetRelComment)
|
|
|
|
| RMRenameRelationship !(AnyBackend RenameRel)
|
|
|
|
|
|
|
|
-- Tables remote relationships
|
|
|
|
| RMCreateRemoteRelationship !(AnyBackend RemoteRelationship)
|
|
|
|
| RMUpdateRemoteRelationship !(AnyBackend RemoteRelationship)
|
|
|
|
| RMDeleteRemoteRelationship !(DeleteRemoteRelationship ('Postgres 'Vanilla))
|
|
|
|
|
|
|
|
-- Functions
|
|
|
|
| RMTrackFunction !(AnyBackend TrackFunctionV2)
|
|
|
|
| RMUntrackFunction !(AnyBackend UnTrackFunction)
|
|
|
|
|
|
|
|
-- Functions permissions
|
Clean metadata arguments
## Description
Thanks to #1664, the Metadata API types no longer require a `ToJSON` instance. This PR follows up with a cleanup of the types of the arguments to the metadata API:
- whenever possible, it moves those argument types to where they're used (RQL.DDL.*)
- it removes all unrequired instances (mostly `ToJSON`)
This PR does not attempt to do it for _all_ such argument types. For some of the metadata operations, the type used to describe the argument to the API and used to represent the value in the metadata are one and the same (like for `CreateEndpoint`). Sometimes, the two types are intertwined in complex ways (`RemoteRelationship` and `RemoteRelationshipDef`). In the spirit of only doing uncontroversial cleaning work, this PR only moves types that are not used outside of RQL.DDL.
Furthermore, this is a small step towards separating the different types all jumbled together in RQL.Types.
## Notes
This PR also improves several `FromJSON` instances to make use of `withObject`, and to use a human readable string instead of a type name in error messages whenever possible. For instance:
- before: `expected Object for Object, but encountered X`
after: `expected Object for add computed field, but encountered X`
- before: `Expecting an object for update query`
after: `expected Object for update query, but encountered X`
This PR also renames `CreateFunctionPermission` to `FunctionPermissionArgument`, to remove the quite surprising `type DropFunctionPermission = CreateFunctionPermission`.
This PR also deletes some dead code, mostly in RQL.DML.
This PR also moves a PG-specific source resolving function from DDL.Schema.Source to the only place where it is used: App.hs.
https://github.com/hasura/graphql-engine-mono/pull/1844
GitOrigin-RevId: a594521194bb7fe6a111b02a9e099896f9fed59c
2021-07-27 13:41:42 +03:00
|
|
|
| RMCreateFunctionPermission !(AnyBackend FunctionPermissionArgument)
|
|
|
|
| RMDropFunctionPermission !(AnyBackend FunctionPermissionArgument)
|
2021-07-07 04:43:42 +03:00
|
|
|
|
|
|
|
-- Computed fields (PG-specific)
|
|
|
|
| RMAddComputedField !(AddComputedField ('Postgres 'Vanilla))
|
|
|
|
| RMDropComputedField !(DropComputedField ('Postgres 'Vanilla))
|
|
|
|
|
2021-09-09 14:54:19 +03:00
|
|
|
-- Tables event triggers
|
|
|
|
| RMCreateEventTrigger !(AnyBackend CreateEventTriggerQuery)
|
|
|
|
| RMDeleteEventTrigger !(AnyBackend DeleteEventTriggerQuery)
|
|
|
|
| RMRedeliverEvent !(AnyBackend RedeliverEventQuery)
|
2021-09-06 14:15:36 +03:00
|
|
|
| RMInvokeEventTrigger !(AnyBackend InvokeEventTriggerQuery)
|
2021-07-07 04:43:42 +03:00
|
|
|
|
|
|
|
-- Remote schemas
|
|
|
|
| RMAddRemoteSchema !AddRemoteSchemaQuery
|
|
|
|
| RMUpdateRemoteSchema !AddRemoteSchemaQuery
|
|
|
|
| RMRemoveRemoteSchema !RemoteSchemaNameQuery
|
|
|
|
| RMReloadRemoteSchema !RemoteSchemaNameQuery
|
|
|
|
| RMIntrospectRemoteSchema !RemoteSchemaNameQuery
|
|
|
|
|
|
|
|
-- Remote schemas permissions
|
2021-08-09 13:20:04 +03:00
|
|
|
| RMAddRemoteSchemaPermissions !AddRemoteSchemaPermission
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMDropRemoteSchemaPermissions !DropRemoteSchemaPermissions
|
|
|
|
|
|
|
|
-- Scheduled triggers
|
|
|
|
| RMCreateCronTrigger !CreateCronTrigger
|
|
|
|
| RMDeleteCronTrigger !ScheduledTriggerName
|
|
|
|
| RMCreateScheduledEvent !CreateScheduledEvent
|
|
|
|
| RMDeleteScheduledEvent !DeleteScheduledEvent
|
|
|
|
| RMGetScheduledEvents !GetScheduledEvents
|
|
|
|
| RMGetEventInvocations !GetEventInvocations
|
|
|
|
|
|
|
|
-- Actions
|
|
|
|
| RMCreateAction !CreateAction
|
|
|
|
| RMDropAction !DropAction
|
|
|
|
| RMUpdateAction !UpdateAction
|
|
|
|
| RMCreateActionPermission !CreateActionPermission
|
|
|
|
| RMDropActionPermission !DropActionPermission
|
|
|
|
|
|
|
|
-- Query collections, allow list related
|
|
|
|
| RMCreateQueryCollection !CreateCollection
|
|
|
|
| RMDropQueryCollection !DropCollection
|
|
|
|
| RMAddQueryToCollection !AddQueryToCollection
|
|
|
|
| RMDropQueryFromCollection !DropQueryFromCollection
|
|
|
|
| RMAddCollectionToAllowlist !CollectionReq
|
|
|
|
| RMDropCollectionFromAllowlist !CollectionReq
|
|
|
|
|
|
|
|
-- Rest endpoints
|
|
|
|
| RMCreateRestEndpoint !CreateEndpoint
|
|
|
|
| RMDropRestEndpoint !DropEndpoint
|
|
|
|
|
|
|
|
-- Custom types
|
|
|
|
| RMSetCustomTypes !CustomTypes
|
|
|
|
|
|
|
|
-- Api limits
|
|
|
|
| RMSetApiLimits !ApiLimit
|
|
|
|
| RMRemoveApiLimits
|
|
|
|
|
|
|
|
-- Metrics config
|
|
|
|
| RMSetMetricsConfig !MetricsConfig
|
|
|
|
| RMRemoveMetricsConfig
|
|
|
|
|
|
|
|
-- Inherited roles
|
2021-07-17 00:18:58 +03:00
|
|
|
| RMAddInheritedRole !InheritedRole
|
2021-07-07 04:43:42 +03:00
|
|
|
| RMDropInheritedRole !DropInheritedRole
|
|
|
|
|
|
|
|
-- Metadata management
|
|
|
|
| RMReplaceMetadata !ReplaceMetadata
|
|
|
|
| RMExportMetadata !ExportMetadata
|
|
|
|
| RMClearMetadata !ClearMetadata
|
|
|
|
| RMReloadMetadata !ReloadMetadata
|
|
|
|
| RMGetInconsistentMetadata !GetInconsistentMetadata
|
|
|
|
| RMDropInconsistentMetadata !DropInconsistentMetadata
|
|
|
|
|
|
|
|
-- Introspection options
|
|
|
|
| RMSetGraphqlSchemaIntrospectionOptions !SetGraphqlIntrospectionOptions
|
|
|
|
|
2021-08-24 10:36:32 +03:00
|
|
|
-- Network
|
|
|
|
| RMAddHostToTLSAllowlist !AddHostToTLSAllowlist
|
|
|
|
| RMDropHostFromTLSAllowlist !DropHostFromTLSAllowlist
|
|
|
|
|
2021-09-23 15:37:56 +03:00
|
|
|
-- QueryTags
|
|
|
|
| RMSetQueryTagsConfig !SetQueryTagsConfig
|
|
|
|
|
2021-07-07 04:43:42 +03:00
|
|
|
-- Debug
|
|
|
|
| RMDumpInternalState !DumpInternalState
|
|
|
|
| RMGetCatalogState !GetCatalogState
|
|
|
|
| RMSetCatalogState !SetCatalogState
|
2021-09-16 14:03:01 +03:00
|
|
|
| RMValidateWebhookTransform !ValidateWebhookTransform
|
2021-07-07 04:43:42 +03:00
|
|
|
|
|
|
|
-- Bulk metadata queries
|
|
|
|
| RMBulk [RQLMetadataRequest]
|
|
|
|
|
|
|
|
|
|
|
|
data RQLMetadataV2
|
|
|
|
= RMV2ReplaceMetadata !ReplaceMetadataV2
|
|
|
|
| RMV2ExportMetadata !ExportMetadata
|
|
|
|
|
|
|
|
data RQLMetadataRequest
|
|
|
|
= RMV1 !RQLMetadataV1
|
|
|
|
| RMV2 !RQLMetadataV2
|