Skip to content

Module ‘GraphQL.Value’ does not export ‘toValue’ #180

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

Open
theobat opened this issue May 4, 2018 · 3 comments
Open

Module ‘GraphQL.Value’ does not export ‘toValue’ #180

theobat opened this issue May 4, 2018 · 3 comments
Labels

Comments

@theobat
Copy link
Contributor

theobat commented May 4, 2018

In the examples folder the input object example use the following import statement which is not compiling:

-- this fails with Module ‘GraphQL.Value’ does not export ‘toValue’
import GraphQL.Value (FromValue, toValue)
-- this is working though :
import GraphQL.Value.ToValue (toValue)
import GraphQL.Value.FromValue (FromValue)

Any idea what's going on ?

@jml
Copy link
Collaborator

jml commented May 6, 2018

No. This compiles and executes from master, both in CI and on my laptop.

Perhaps if you provided a minimal, reproducible set of steps which demonstrated the problem, along with a full error message we'd be in a better position to help (c.f. http://sscce.org/).

@jml jml added the question label May 6, 2018
@theobat
Copy link
Contributor Author

theobat commented May 7, 2018

Hey, thanks for your answer, so here's what I did:

  • created a new project using stack
  • added the following dependencies in package.yaml
  • I'm using ghc 8.2.2 and stack 1.6.1 on macOS Sierra 10.12.6 (16G1314)
dependencies:
- base >= 4.7 && < 5
- graphql-api == 0.3.0
- protolude == 0.2.2
- aeson == 1.3.1.0
- text 

And merely copied/pasted the examples in Main.hs:

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE NoImplicitPrelude #-}

module Main (main) where

import Protolude hiding (Enum)

import qualified Data.Aeson as Aeson

import GraphQL
import GraphQL.API
import GraphQL.Resolver (Handler)
-- import GraphQL.Value.ToValue (toValue)
-- import GraphQL.Value.FromValue (FromValue)
import GraphQL.Value (FromValue, toValue)

data DogStuff = DogStuff { _toy :: Text, _likesTreats :: Bool } deriving (Show, Generic)
instance FromValue DogStuff
instance HasAnnotatedInputType DogStuff
instance Defaultable DogStuff where
  defaultFor _ = Just (DogStuff "shoe" False)

type Query = Object "Query" '[]
  '[ Argument "dogStuff" DogStuff :> Field "description" Text ]

root :: Handler IO Query
root = pure description

description :: DogStuff -> Handler IO Text
description (DogStuff toy likesTreats)
  | likesTreats = pure $ "likes treats and their favorite toy is a " <> toy
  | otherwise = pure $ "their favorite toy is a " <> toy

example :: Text -> IO Response
example = interpretAnonymousQuery @Query root

main :: IO ()
main = do
  response <- example "{ description(dogStuff: {_toy: \"bone\", _likesTreats: true}) }"
  putStrLn $ Aeson.encode $ toValue response
  response' <- example "{ description }"
  putStrLn $ Aeson.encode $ toValue response'

I did give you all the meaningful error from the compiler:

➜  haskell-api-test git:(master) ✗ stack build
helloworld-0.1.0.0: unregistering (local file changes: app/Main.hs)
helloworld-0.1.0.0: build (lib + exe)
Preprocessing library for helloworld-0.1.0.0..
Building library for helloworld-0.1.0.0..
Preprocessing executable 'helloworld-exe' for helloworld-0.1.0.0..
Building executable 'helloworld-exe' for helloworld-0.1.0.0..
[2 of 2] Compiling Main             ( app/Main.hs, .stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/helloworld-exe/helloworld-exe-tmp/Main.o )

.../haskell-api-test/app/Main.hs:19:23: error:
    Module ‘GraphQL.Value’ does not export ‘FromValue’
   |
19 | import GraphQL.Value (FromValue, toValue)
   |                       ^^^^^^^^^

.../haskell-api-test/app/Main.hs:19:34: error:
    Module ‘GraphQL.Value’ does not export ‘toValue’
   |
19 | import GraphQL.Value (FromValue, toValue)
   |                                  ^^^^^^^

And these errors go away when I replace these imports with the two lines I commented in the snippet above.

@jml
Copy link
Collaborator

jml commented May 7, 2018

Thanks. That makes things much clearer.

The examples in master work with master. We have moved modules around since 0.3.0 and have not yet released it.

You can see the examples for 0.3.0 here: https://github.com/haskell-graphql/graphql-api/tree/v0.3.0/tests/Examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants