eskimor / servant-purescript

Translate servant API to purescript code, with the help of purescript-bridge.
BSD 3-Clause "New" or "Revised" License
105 stars 44 forks source link

Code generation for query parameters is completely untested #8

Closed eskimor closed 7 years ago

eskimor commented 8 years ago

Generated code might not even compile or not work - if you experience any issues with query parameters - please report them -I'll fix them asap.

parsonsmatt commented 8 years ago

(ignore that -- I was using the wrong version of the program in the example project :sweat_smile:)

legrostdg commented 7 years ago

I am experiencing problems with a QueryParam:

QueryParam "file" FilePath :> Get '[JSON] Int

gives

getMovieGet :: forall eff m.
               (MonadReader (SPSettings_ SPParams_) m, MonadError AjaxError m, MonadAff ( ajax :: AJAX | eff) m)
               => String -> m Int
getMovieGet file = do
  spOpts_' <- ask
  let spOpts_ = case spOpts_' of SPSettings_ o -> o
  let spParams_ = case spOpts_.params of SPParams_ ps_ -> ps_
  let baseURL = spParams_.baseURL
  let httpMethod = "GET"
  let reqUrl = baseURL <> "movie" <> "/" <> "get" 
        <> "?" <> encodeQuery "file" file
  let reqHeaders =
        []
  affResp <- liftAff $ affjax defaultRequest
                                { method = httpMethod
                                , url = reqUrl
                                , headers = defaultRequest.headers <> reqHeaders
                                }
  getResult decodeJson affResp

but encodeQuery is invalid:

$ pulp build
* Building project in /home/user/src/app/app-client-web/frontend
Compiling ServerAPI
Error found:
in module ServerAPI
at /home/user/src/app/app-client-web/frontend/src/ServerAPI.purs line 114, column 16 - line 115, column 42

  Unknown value encodeQuery

See https://github.com/purescript/purescript/wiki/Error-Code-UnknownName for more information,
or to contribute content related to this error.

* ERROR: Subcommand terminated with exit code 1
eskimor commented 7 years ago

Thank you - I'll have a look!

eskimor commented 7 years ago

Which version of servant-purescript are you using?

legrostdg commented 7 years ago
$ stack list-dependencies | grep servant-purescript
servant-purescript 0.6.0.0
eskimor commented 7 years ago

This is really strange - the said function does not exist in servant-purescript-0.6.0.0. Anyway I am currently sick and on a tight schedule (where it really does not help being sick), so if anyone can have a look at this, it would be really much appreciated, otherwise I hope to find some time soon.

legrostdg commented 7 years ago

OK, I found it: I had changed the name of my executable in my .cabal file, and was still using "stack exec -- old-executable-name"... Sorry about that!

eskimor commented 7 years ago

nop!