graphql-engine/server/src-lib/Hasura/GraphQL/Schema/Postgres.hs
Robert 11a454c2d6 server, pro: actually reformat the code-base using ormolu
This commit applies ormolu to the whole Haskell code base by running `make format`.

For in-flight branches, simply merging changes from `main` will result in merge conflicts.
To avoid this, update your branch using the following instructions. Replace `<format-commit>`
by the hash of *this* commit.

$ git checkout my-feature-branch
$ git merge <format-commit>^    # and resolve conflicts normally
$ make format
$ git commit -a -m "reformat with ormolu"
$ git merge -s ours post-ormolu

https://github.com/hasura/graphql-engine-mono/pull/2404

GitOrigin-RevId: 75049f5c12f430c615eafb4c6b8e83e371e01c8e
2021-09-23 22:57:37 +00:00

54 lines
2.1 KiB
Haskell

-- | Postgres-specific schema combinators. Those should be moved to
-- the corresponding instance of `BackendSchema`, when actions are
-- generalized.
module Hasura.GraphQL.Schema.Postgres
( buildActionQueryFields,
buildActionSubscriptionFields,
buildActionMutationFields,
)
where
import Hasura.GraphQL.Parser hiding (EnumValueInfo, field)
import Hasura.GraphQL.Schema.Action
import Hasura.GraphQL.Schema.Backend (MonadBuildSchema)
import Hasura.Prelude
import Hasura.RQL.IR
import Hasura.RQL.Types
buildActionQueryFields ::
MonadBuildSchema ('Postgres 'Vanilla) r m n =>
NonObjectTypeMap ->
ActionInfo ->
m [FieldParser n (QueryRootField UnpreparedValue)]
buildActionQueryFields nonObjectCustomTypes actionInfo =
maybeToList <$> case _adType (_aiDefinition actionInfo) of
ActionQuery ->
fmap (fmap (RFAction . AQQuery)) <$> actionExecute nonObjectCustomTypes actionInfo
ActionMutation ActionSynchronous -> pure Nothing
ActionMutation ActionAsynchronous ->
fmap (fmap (RFAction . AQAsync)) <$> actionAsyncQuery actionInfo
buildActionMutationFields ::
MonadBuildSchema ('Postgres 'Vanilla) r m n =>
NonObjectTypeMap ->
ActionInfo ->
m [FieldParser n (MutationRootField UnpreparedValue)]
buildActionMutationFields nonObjectCustomTypes actionInfo =
maybeToList <$> case _adType (_aiDefinition actionInfo) of
ActionQuery -> pure Nothing
ActionMutation ActionSynchronous ->
fmap (fmap (RFAction . AMSync)) <$> actionExecute nonObjectCustomTypes actionInfo
ActionMutation ActionAsynchronous ->
fmap (fmap (RFAction . AMAsync)) <$> actionAsyncMutation nonObjectCustomTypes actionInfo
buildActionSubscriptionFields ::
MonadBuildSchema ('Postgres 'Vanilla) r m n =>
ActionInfo ->
m [FieldParser n (QueryRootField UnpreparedValue)]
buildActionSubscriptionFields actionInfo =
maybeToList <$> case _adType (_aiDefinition actionInfo) of
ActionQuery -> pure Nothing
ActionMutation ActionSynchronous -> pure Nothing
ActionMutation ActionAsynchronous ->
fmap (fmap (RFAction . AQAsync)) <$> actionAsyncQuery actionInfo