Closed ashwinv11 closed 3 months ago
@ashwinv11 Currently, you can create the file bindings.d.ts
for binding KV Namespace...
For example: https://github.com/kimyvgy/worker-apollo-server-template/blob/main/bindings.d.ts
Thanks @kimyvgy! I actually found your repo and tried that out, however I'm getting a Context creation failed: GRAPHQL_KV_CACHE is not defined
error when attempting to use the bindings.d.ts
. When I clone and deploy your template I don't see that issue so must be something else I'm missing. I'll keep investigating and update here
Ah I think I understand why now, I'm writing my worker code using the newer ESM syntax vs the Service Worker format. With the former, env variables are no longer accessible via globals and looks like they must be passed down from the handler context. Would it be possible to consider adding this feature for the newer syntax style?
I have the same issue here; I need to pass in env in a handler. Did you ever figure out a solution to this @ashwinv11?
@simplenotezy @ashwinv11 The PR #80 solved this issue. Please upgrade your app to ^v1.0.0.
Nice, thanks @kimyvgy - is it as simple as calling the global variable? Or could you share som example of how to grab the env
First off, thank you for creating this!
It would be very useful if we could pass additional information like environment variables to the
CloudflareWorkersHandler
to thehandleGraphQLRequest
function. This would allow us to reference sensitive info like DB connection fields, the Cloudflare KV Namespace that's bound to the worker, and much more.This would allow us to reference connections to persistence layers in DataSource classes within the context object.
Is there some way to do this today that I might be missing? Thank you!