New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Context-switch? #26
Comments
Hello, Superlifter's operation is pretty disconnected from Lacinia's - this is the only way it can achieve the Dataloader functionality. Essentially you create a superlifter instance and throw fetches into it from Lacinia and it returns a promise that Lacinia understands, but it has no knowledge of resolvers or ancestry. The fetches are also performed on a thread pool so thread local bindings won't work either. One way to achieve this is to alter the Lacinia context appropriately for child resolvers and make this an argument to your fetches, which are just records so can contain extra information for the fetch itself. Can you think of any other ways? Cheers |
Yup. That's exactly what I'm trying. In my case the context in question is a Datomic DB (kind like a DB snapshot). What do you think if I lazily create a bucket if there isn't one? I'll have to peek into superlifter's context. Is it acceptable usage? (defn- has-bucket? [context bucket-id]
(contains? @(get context :buckets)
bucket-id))
(defn enqueue! [{:keys [superlifter]} {:keys [muse bucket-id env]}]
(when-not (has-bucket? superlifter bucket-id)
(s/add-bucket! superlifter bucket-id (assoc-in default-bucket-options
[:urania-opts :env]
env)))
(s/enqueue! superlifter bucket-id muse)) |
Looks generally ok, you need to be careful of two things:
Superlifter could make this a bit easier for you, either with a way to check the buckets or an atomic way of adding a bucket. Let me know what you settle on and we can see if there are some useful improvements to the superlifter API. |
Sounds cool. |
Reading the implementation of |
Hi @hden reading this now, superlifter has an atomic way to add a bucket, which would mean you don't need to check for the existence of one first. If I've not misunderstood, are you happy for this to be closed? Thanks |
Sure. Thanks for reaching out. |
When used with Lacinia, it is useful to allow a field resolver to modify the application context, with the change exposed just to the fields nested below, but to any depth.
(resolve/with-context result new-context)
In our specific use-case, we'd like to update a specific db parameter for just to the field below. However superlifter requires the parameter to be placed in its context. We are able to specify the initial context via the
:urania-opts
key, but what's the recommended way to update the urania env just to the fields nested below, but to any depth?Refs:
The text was updated successfully, but these errors were encountered: