Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Directive composition #152

Open
JoviDeCroock opened this issue Jan 10, 2020 · 4 comments
Open

Directive composition #152

JoviDeCroock opened this issue Jan 10, 2020 · 4 comments

Comments

@JoviDeCroock
Copy link

Idea

Related to #146 I'd like to extend our traverser to have a certain set of directives like the one proposed in the issue @extra. When passed to the cacheExchange it would automatically stop at these directives, strip them out and execute a callback allowing you to return an altered operation, ....

This would for example allow you to add more variables, allow the populateExchange to become a HOC passed into this object.

Rough example

cacheExchange({
  directives: {
    extra: (op, directiveArgs) => ({ ....op, variables: { ...op.variables, ...directiveArgs }}) 
  }
})

This is very rough and I'll most likely alter this when hacking on it but I would like to send this in to get some more idea's

@andyrichardson
Copy link
Collaborator

andyrichardson commented Jan 10, 2020

I think the order importance of exchanges is a bit of a pain but I'm not sure nesting them inside the cache is the way to go.

Are there any specific decorators that can't be resolved before/after the cache?

@JoviDeCroock
Copy link
Author

Are there any specific decorators that can't be resolved before/after the cache?

No but I'm trying to find a middle ground on this. Much like for instance redux has middlewares it could be used to make our cache smarter (and we need to solve the issue anyway so I thought let's look for a very extendable solution)

@kitten
Copy link
Member

kitten commented Jan 10, 2020

I think it's sufficient to fix #146 in isolation :)

@JoviDeCroock
Copy link
Author

@kitten do you agree with @andyrichardson to catch a directive like extra in a separate exchange?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants