Skip to content

Commit

Permalink
Add defineBy*File' variant that takes a Q FilePath
Browse files Browse the repository at this point in the history
This enables using utilities such as
https://hackage.haskell.org/package/file-embed-0.0.13.0/docs/Data-FileEmbed.html#v:makeRelativeToProject
which can be used to work around file path issues when using multi
package projects.
  • Loading branch information
AlistairB committed Mar 24, 2021
1 parent f76f54e commit b88e9e3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions morpheus-graphql-client/src/Data/Morpheus/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ module Data.Morpheus.Client
defineQuery,
defineByDocument,
defineByDocumentFile,
defineByDocumentFile',
defineByIntrospection,
defineByIntrospectionFile,
defineByIntrospectionFile',
ScalarValue (..),
DecodeScalar (..),
EncodeScalar (..),
Expand Down Expand Up @@ -58,11 +60,17 @@ defineByDocumentFile filePath args = do
qAddDependentFile filePath
defineByDocument (L.readFile filePath) args

defineByDocumentFile' :: Q FilePath -> (ExecutableDocument, String) -> Q [Dec]
defineByDocumentFile' qFilePath args = qFilePath >>= flip defineByDocumentFile args

defineByIntrospectionFile :: FilePath -> (ExecutableDocument, String) -> Q [Dec]
defineByIntrospectionFile filePath args = do
qAddDependentFile filePath
defineByIntrospection (L.readFile filePath) args

defineByIntrospectionFile' :: Q FilePath -> (ExecutableDocument, String) -> Q [Dec]
defineByIntrospectionFile' qFilePath args = qFilePath >>= flip defineByIntrospectionFile args

defineByDocument :: IO ByteString -> (ExecutableDocument, String) -> Q [Dec]
defineByDocument doc = defineQuery (schemaByDocument doc)

Expand Down

0 comments on commit b88e9e3

Please sign in to comment.