-
Notifications
You must be signed in to change notification settings - Fork 2.8k
auto-include __typename field in custom types' objects (fix #4063)
#4074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7f34566
2433c21
781a057
5f20ce3
ff9f317
8024205
876c340
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ import Hasura.Prelude | |
| import qualified Data.Aeson as J | ||
| import qualified Data.ByteString.Lazy as BL | ||
| import qualified Data.HashMap.Strict as Map | ||
| import qualified Data.HashSet as Set | ||
| import qualified Data.Text as T | ||
| import qualified Language.GraphQL.Draft.Parser as G | ||
| import qualified Language.GraphQL.Draft.Syntax as G | ||
|
|
@@ -159,43 +158,10 @@ mergeQueryRoot :: GS.GCtx -> GS.GCtx -> VT.ObjTyInfo | |
| mergeQueryRoot a b = GS._gQueryRoot a <> GS._gQueryRoot b | ||
|
|
||
| mergeMutRoot :: GS.GCtx -> GS.GCtx -> Maybe VT.ObjTyInfo | ||
| mergeMutRoot a b = | ||
| let objA' = fromMaybe mempty $ GS._gMutRoot a | ||
| objB = fromMaybe mempty $ GS._gMutRoot b | ||
| objA = newRootOrEmpty objA' objB | ||
| merged = objA <> objB | ||
| in bool (Just merged) Nothing $ merged == mempty | ||
| where | ||
| newRootOrEmpty x y = | ||
| if x == mempty && y /= mempty | ||
| then mkNewEmptyMutRoot | ||
| else x | ||
|
|
||
| mkNewEmptyMutRoot :: VT.ObjTyInfo | ||
| mkNewEmptyMutRoot = VT.ObjTyInfo (Just "mutation root") | ||
| (G.NamedType "mutation_root") Set.empty Map.empty | ||
|
|
||
| mkNewMutRoot :: VT.ObjFieldMap -> VT.ObjTyInfo | ||
| mkNewMutRoot flds = VT.ObjTyInfo (Just "mutation root") | ||
| (G.NamedType "mutation_root") Set.empty flds | ||
| mergeMutRoot a b = GS._gMutRoot a <> GS._gMutRoot b | ||
|
|
||
| mergeSubRoot :: GS.GCtx -> GS.GCtx -> Maybe VT.ObjTyInfo | ||
| mergeSubRoot a b = | ||
| let objA' = fromMaybe mempty $ GS._gSubRoot a | ||
| objB = fromMaybe mempty $ GS._gSubRoot b | ||
| objA = newRootOrEmpty objA' objB | ||
| merged = objA <> objB | ||
| in bool (Just merged) Nothing $ merged == mempty | ||
| where | ||
| newRootOrEmpty x y = | ||
| if x == mempty && y /= mempty | ||
| then mkNewEmptySubRoot | ||
| else x | ||
|
|
||
| mkNewEmptySubRoot :: VT.ObjTyInfo | ||
| mkNewEmptySubRoot = VT.ObjTyInfo (Just "subscription root") | ||
| (G.NamedType "subscription_root") Set.empty Map.empty | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The explanation in above comment applicable here for subscription roots. |
||
|
|
||
| mergeSubRoot a b = GS._gSubRoot a <> GS._gSubRoot b | ||
|
|
||
| mergeTyMaps | ||
| :: VT.TypeMap | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,7 +210,7 @@ resolveAsyncActionQuery userInfo selectOpCtx field = do | |
|
|
||
| annotatedFields <- fmap (map (first FieldName)) $ withSelSet (_fSelSet field) $ \fld -> | ||
| case _fName fld of | ||
| "__typename" -> return $ RS.FExp $ G.unName $ G.unNamedType $ _fType fld | ||
| "__typename" -> return $ RS.FExp $ G.unName $ G.unNamedType $ _fType field | ||
| "output" -> do | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
| -- See Note [Resolving async action query/subscription] | ||
| let inputTableArgument = RS.AETableRow $ Just $ Iden "response_payload" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe ahas Semigroup instance. So,<>can be directly used to mergeMaybe mutationRoots here. No need formkNewEmptyMutRoot.