We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
this code:
type Friend = Object "Friend" '[] '[ Field "id" Text.Text, Field "email" Text.Text ] type User = Object "User" '[] '[ Field "id" Text.Text, Field "email" Text.Text, Field "friends" (List Friend) ] type UserQuery = Object "UserQuery" '[] '[ Argument "id" Text.Text :> Field "user" (Maybe User) ] friendHandler :: DbUser.DbUser -> Handler IO Friend friendHandler DbUser.DbUser {..} = pure $ pure ((Text.pack . show) _id) :<> pure _email friendsHandler :: [DbUser.DbUser] -> Handler IO (List Friend) friendsHandler friends = pure $ map friendHandler friends userHandler :: Int -> Text.Text -> [DbUser.DbUser] -> Handler IO User userHandler id email friends = pure $ pure ((Text.pack . show) id) :<> pure email :<> friendsHandler friends userQueryHandler :: PSQL.Connection -> Handler IO UserQuery userQueryHandler dbConn = pure $ \userId -> do result <- Db.getUserById dbConn (read @Int $ Text.unpack userId) case result of [DbUser.DbUser {..}] -> do friends <- Db.getUsersByIds dbConn _friendsIds pure $ Just $ userHandler _id _email friends _ -> pure Nothing
and query:
{ user(id: "1") { id email friends } }
compiled successfully, but with errors in a response:
{ "data": { "user": { "email": "[email protected]", "id": "1", "friends": [ null ] } }, "errors": [ { "message": "Tried to treat object as if it were leaf field." } ] }
But if i change type
type User = Object "User" '[] '[ Field "id" Text.Text, Field "email" Text.Text, Field "friends" (List Text.Text) ]
everything works
So, what I did wrong and what this error means? Thanks for any help.
ghc - 8.6.5 graphql-api-0.3.0
The text was updated successfully, but these errors were encountered:
No branches or pull requests
this code:
and query:
compiled successfully, but with errors in a response:
But if i change type
everything works
So, what I did wrong and what this error means? Thanks for any help.
ghc - 8.6.5
graphql-api-0.3.0
The text was updated successfully, but these errors were encountered: