Open xmlking opened 1 year ago
@xmlking
It worked for me when using the syntax :
subscriptionsEndpoint: "${MY_SERVICE}/graphql"
Instead of {env.MY_SERVICE}
Thanks for letting me know. Will they this solution. I recall @ardatan mentioned someway disadvantage of using this way for accessing environment variables.
I have the same problem with the mongoose handler and the connectionString
field. Either syntax just throws the following error:
MongoParseError: Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://"
at new ConnectionString (/workspaces/api/node_modules/mongodb-connection-string-url/src/index.ts:133:13)
at parseOptions (/workspaces/api/node_modules/mongodb/src/connection_string.ts:245:15)
at new MongoClient (/workspaces/api/node_modules/mongodb/src/mongo_client.ts:359:34)
at NativeConnection.createClient (/workspaces/api/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js:293:14)
at NativeConnection.openUri (/workspaces/api/node_modules/mongoose/lib/connection.js:779:34)
at connect (/workspaces/api/node_modules/mongoose/lib/mongoose.js:404:15)
at MongooseHandler.getMeshSource (/workspaces/api/node_modules/@graphql-mesh/mongoose/cjs/index.js:40:36)
at /workspaces/api/node_modules/@graphql-mesh/runtime/cjs/get-mesh.js:90:52
at Array.map (<anonymous>)
at getMesh (/workspaces/api/node_modules/@graphql-mesh/runtime/cjs/get-mesh.js:85:38)
Seems that environment variables are super limited in where they can be applied to config. I also tried adding statsd plugin with
plugins:
- statsd:
client:
host: '{env.DD_AGENT_HOST}'
and getting the following error in the logs
Error: Error sending hot-shots message: Error: getaddrinfo ENOTFOUND {env.DD_AGENT_HOST}
I can hack a fix for the second problem (statsd plugin) in my case by doing a build, then doing a search and replace on the generated .mesh/index.ts
file before starting.
package.json
"scripts": {
"build": "mesh build && npx -y https://github.com/vatfree/env-replace.git .mesh/index.ts",
"start": "yarn build && mesh start"
}
but the mongoose host is required before the build and replacing the .meshrc.yaml
file will alter the source code in a destructive way.
Turns out the above hack was unnecessary, since the underlying hot-shots package will try to use the DD_AGENT_HOST environment variable by default if no host was specified. So best to just not specify it like:
plugins:
- statsd:
# client:
# host: '{env.DD_AGENT_HOST}'
environment variables not working with GraphQL Handler endpoint when invoking subscriptions. I have to give real URL. I even tried to provide
subscriptionsEndpoint
via environment variables without any luck. This is preventing us deploying to different environments without hardcoding endpoints...Queries and Mutations works fine when setting GraphQL endpoint via environment variables.
Error