Skip to content

Commit 2b127cb

Browse files
authored
Add a hack to support multiple aggregate entities on Hosted Service (#676)
1 parent 87c1c78 commit 2b127cb

File tree

1 file changed

+18
-2
lines changed
  • codegenerator/cli/templates/static/codegen/src

1 file changed

+18
-2
lines changed

codegenerator/cli/templates/static/codegen/src/Env.res

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,24 @@ module Hasura = {
164164

165165
let secret = envSafe->EnvSafe.get("HASURA_GRAPHQL_ADMIN_SECRET", S.string, ~devFallback="testing")
166166

167-
let aggregateEntities =
168-
envSafe->EnvSafe.get("ENVIO_HASURA_PUBLIC_AGGREGATE", S.array(S.string), ~fallback=[])
167+
let aggregateEntities = envSafe->EnvSafe.get(
168+
"ENVIO_HASURA_PUBLIC_AGGREGATE",
169+
S.union([
170+
S.array(S.string),
171+
// Temporary workaround: Hosted Service can't use commas in env vars for multiple entities.
172+
// Will be removed once comma support is added — don't rely on this.
173+
S.string->S.transform(s => {
174+
parser: string =>
175+
switch string->Js.String2.split("&") {
176+
| []
177+
| [_] =>
178+
s.fail(`Provide an array of entities in the JSON format.`)
179+
| entities => entities
180+
},
181+
}),
182+
]),
183+
~fallback=[],
184+
)
169185
}
170186

171187
module Configurable = {

0 commit comments

Comments
 (0)