Add setVariables
to data
#472
Comments
The correct way to change variables in React is to pass in a new set of variables to props. This may be worth reconsidering. |
I'm not sure if it would be good to start introducing a lot of state into the React HoC - perhaps we should suggest an approach where state is kept outside? https://dev-blog.apollodata.com/simplify-your-react-components-with-apollo-and-recompose-8b9e302dea51#.jxb1nyyih Alternatively we could make state a primary function for stuff like keeping pagination variables etc. |
I don't understand how refetch can work but setVariabnes not?
…On Wed, Feb 22, 2017, 3:32 AM Sashko Stubailo ***@***.***> wrote:
I'm not sure if it would be good to start introducing a lot of state into
the React HoC - perhaps we should suggest an approach where state is kept
outside?
https://dev-blog.apollodata.com/simplify-your-react-components-with-apollo-and-recompose-8b9e302dea51#.jxb1nyyih
Alternatively we could make state a primary function for stuff like
keeping pagination variables etc.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#472 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADWlk-l9pUeY-1C9R8t-uCaS3pg0S1Yks5re55TgaJpZM4MH7gn>
.
|
Also, HoC typically have state, eg Redux' connect.
…On Wed, Feb 22, 2017, 7:05 AM Wout Mertens ***@***.***> wrote:
I don't understand how refetch can work but setVariabnes not?
On Wed, Feb 22, 2017, 3:32 AM Sashko Stubailo ***@***.***>
wrote:
I'm not sure if it would be good to start introducing a lot of state into
the React HoC - perhaps we should suggest an approach where state is kept
outside?
https://dev-blog.apollodata.com/simplify-your-react-components-with-apollo-and-recompose-8b9e302dea51#.jxb1nyyih
Alternatively we could make state a primary function for stuff like
keeping pagination variables etc.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#472 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADWlk-l9pUeY-1C9R8t-uCaS3pg0S1Yks5re55TgaJpZM4MH7gn>
.
|
@wmertens I’m not even sure if It isn’t so much about whether or not we should introduce state into an HoC, but more so that we have already made the decision that |
@calebmer IMHO This can be done in a completely backwards compatible manner, presumably at virtually no runtime cost. Not having |
The problem with that is that when the |
My first instinct would be to replace. Perhaps there can be a second
parameter to the options function with the current state, for if the dev
wants custom merging?
…On Wed, Mar 1, 2017 at 4:42 PM Caleb Meredith ***@***.***> wrote:
The problem with that is that when the variables prop changes we are in
the awkward position of needing to either blow away the variables set with
setVariables, or merge them together 😣
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#472 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADWlp9a0_39ZZrAXx4cd8Bia9uxPZ7Wks5rhZIDgaJpZM4MH7gn>
.
|
I really think that variables should be given by props and not set internally in the component. If you have a specific use-case where this would be useful, please add a clear description here: apollographql/apollo-client#1391 |
I just stumbled across this issue. I was actually pleasantly surprised to see that variables can be passed to If Anyhow, the compose(
withState('sort', 'onUpdateSort', 'created,desc'),
graphql(query, {options: ({sort}) => ({variables: {sort}})})
)(SomeComponent); This works fine for me, although it would be nice to not having to wrap another HOC around. Maybe it would make sense to provide state if |
Refetch is fantastic until you need to delete a variable that is fetched. You can't just set |
Foo:undefined?
…On Sat, Sep 2, 2017, 7:32 PM Josh Taylor ***@***.***> wrote:
Refetch is fantastic until you need to delete a variable that is fetched.
You can't just set foo: null, because foo might have a null value.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#472 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADWlnA9dHGEKqKQ9Jd3hZqBXhFsD4_Oks5seZFAgaJpZM4MH7gn>
.
|
Yeah, ended up doing that, sorry forgot to loop back here and update it. The http://facebook.github.io/graphql/#sec-Null-Value caught me out :). |
I found
setVariables
in apollo client and that seems to be super useful for updating a query based on internal state.However, right now it seems to be missing from
data
as provided bygraphql()
. Is there a reason? Can it be included?The text was updated successfully, but these errors were encountered: