mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 12:31:52 +03:00
83ea4a254d
We'd like to be able to build a Schema Cache from only serializable data. We already have Metadata. The data that's missing to build a Schema Cache is referred to as "stored introspection", and this includes: - DB introspection - User-defined enum values (i.e. contents of specific DB tables) - Remote schema introspection This PR introduces a new `StoredIntrospection` container that holds that data, and plumbs it through to the right parts of the schema cache building process, so that stored introspection can be used as a substitute for fresh introspection requests against live data sources. The serialization of `StoredIntrospection` is intended to be straightforward: just take the serialized source introspection results, and put them in an appropriate JSON object. Though I don't think that this PR achieves that entirely. In order for `StoredIntrospection` to be deserializable (through `aeson` instances), while keeping the required code changes low, this piggy-backs off of the `ResolvedSource` data type. `ResolvedSource` is _almost_ exactly what we want, and _almost_ deserializable, so this PR brings it across the finish line by moving a few things out of that type, and adding a `FromJSON (RawFunctionInfo b)` context to the `Backend` type class. [PLAT-270]: https://hasurahq.atlassian.net/browse/PLAT-270?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [PLAT-270]: https://hasurahq.atlassian.net/browse/PLAT-270?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [PLAT-276]: https://hasurahq.atlassian.net/browse/PLAT-276?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [PLAT-276]: https://hasurahq.atlassian.net/browse/PLAT-276?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7053 GitOrigin-RevId: 5001b4ea086195cb5e65886747eac2a0a657b64c
38 lines
905 B
Haskell
38 lines
905 B
Haskell
module Hasura.RemoteSchema.Metadata.Base
|
|
( RemoteSchemaName (..),
|
|
)
|
|
where
|
|
|
|
import Autodocodec (HasCodec (codec), dimapCodec)
|
|
import Data.Aeson qualified as J
|
|
import Data.Text.Extended
|
|
import Data.Text.NonEmpty
|
|
import Database.PG.Query qualified as PG
|
|
import Hasura.Prelude
|
|
|
|
-- | Remote schema identifier.
|
|
--
|
|
-- NOTE: no validation on the character set is done here; it's likely there is
|
|
-- a bug (FIXME) where this interacts with remote relationships and some name
|
|
-- mangling needs to happen.
|
|
newtype RemoteSchemaName = RemoteSchemaName
|
|
{unRemoteSchemaName :: NonEmptyText}
|
|
deriving
|
|
( Show,
|
|
Eq,
|
|
Ord,
|
|
Hashable,
|
|
J.ToJSON,
|
|
J.ToJSONKey,
|
|
J.FromJSON,
|
|
J.FromJSONKey,
|
|
PG.ToPrepArg,
|
|
PG.FromCol,
|
|
ToTxt,
|
|
NFData,
|
|
Generic
|
|
)
|
|
|
|
instance HasCodec RemoteSchemaName where
|
|
codec = dimapCodec RemoteSchemaName unRemoteSchemaName codec
|