Skip to content

Commit a7d73f2

Browse files
committed
Add defineBy*File' variant that takes a Q FilePath
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.
1 parent f76f54e commit a7d73f2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

morpheus-graphql-client/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Minor Changes
6+
7+
- Add defineBy*File' variants that take a `Q FilePath` [#584](https://github.com/morpheusgraphql/morpheus-graphql/pull/584)
8+
39
## 0.17.0 - 25.02.2021
410

511
### Breaking changes

morpheus-graphql-client/src/Data/Morpheus/Client.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ module Data.Morpheus.Client
77
defineQuery,
88
defineByDocument,
99
defineByDocumentFile,
10+
defineByDocumentFile',
1011
defineByIntrospection,
1112
defineByIntrospectionFile,
13+
defineByIntrospectionFile',
1214
ScalarValue (..),
1315
DecodeScalar (..),
1416
EncodeScalar (..),
@@ -58,11 +60,19 @@ defineByDocumentFile filePath args = do
5860
qAddDependentFile filePath
5961
defineByDocument (L.readFile filePath) args
6062

63+
-- | This variant exposes 'Q FilePath' enabling the use of TH to generate the 'FilePath'. For example, https://hackage.haskell.org/package/file-embed-0.0.13.0/docs/Data-FileEmbed.html#v:makeRelativeToProject can be used to handle multi package projects more reliably.
64+
defineByDocumentFile' :: Q FilePath -> (ExecutableDocument, String) -> Q [Dec]
65+
defineByDocumentFile' qFilePath args = qFilePath >>= flip defineByDocumentFile args
66+
6167
defineByIntrospectionFile :: FilePath -> (ExecutableDocument, String) -> Q [Dec]
6268
defineByIntrospectionFile filePath args = do
6369
qAddDependentFile filePath
6470
defineByIntrospection (L.readFile filePath) args
6571

72+
-- | This variant exposes 'Q FilePath' enabling the use of TH to generate the 'FilePath'. For example, https://hackage.haskell.org/package/file-embed-0.0.13.0/docs/Data-FileEmbed.html#v:makeRelativeToProject can be used to handle multi package projects more reliably.
73+
defineByIntrospectionFile' :: Q FilePath -> (ExecutableDocument, String) -> Q [Dec]
74+
defineByIntrospectionFile' qFilePath args = qFilePath >>= flip defineByIntrospectionFile args
75+
6676
defineByDocument :: IO ByteString -> (ExecutableDocument, String) -> Q [Dec]
6777
defineByDocument doc = defineQuery (schemaByDocument doc)
6878

0 commit comments

Comments
 (0)