[Proposal] Pass additional argument to adapters#1325
Merged
particlebanana merged 1 commit intomasterfrom Mar 18, 2016
Merged
Conversation
|
Hi @particlebanana! It looks like your pull request title doesn’t quite conform to our guidelines. Please edit the title so that it starts with [proposal], [patch], [fixes #], or [implements #]. Once you've fixed it, post a comment below (e.g. "ok, fixed!") and we'll take a look! |
|
👍 wow.. |
Contributor
Author
|
@Nishchit14 looking at getting this and the projections pr published as |
particlebanana
added a commit
that referenced
this pull request
Mar 18, 2016
[Proposal] Pass additional argument to adapters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Right now there doesn't exist a way to pass additional metadata for a query down to the adapter. This could be helpful when building custom adapters that need handle things like passing connections around or adding information for multi-tenancy.
This PR adds that ability in a temporary format. For now you can tack on an additional argument to your queries after the callback or use the
.meta()key in the deferred object builder to pass any arbitrary data down to an adapter function.Yes this breaks the common node contract of the callback as the last argument and it's weird. I know this isn't a great longterm solution. If you don't use the extra argument everything will work as expected though. The big plus is it gives us this functionality now without breaking every single one of the community adapters.
In the major version bump to
1.0.0we will retool the function signatures to take an(options, cb)signature so that we can add non-breaking changes in the future.Some examples of usage:
To access the meta value in the adapter you would build a function like so:
For some more background on this see #1307