-
Notifications
You must be signed in to change notification settings - Fork 108
Conversation
}), | ||
networkStatus: apolloData##networkStatus, | ||
}; | ||
let make = | ||
( | ||
~variables: option(Js.Json.t)=?, | ||
~updateQuery: option((Config.t, updateQueryOptions) => Config.t)=?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tricky, because Config.t
is the initial Query, but you should be able to pass any query in the updateQuery?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that is correct. My understanding is that updateQuery
isn't the best name, it's not a new query it's just a function to combine the results from the initial query and a fetchMore
query. The fetchMore query is the original query but can have new variables.
I'm getting this information from: https://www.apollographql.com/docs/react/features/pagination.html I may be interpreting it incorrectly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the link there is a mention:
note this is a different query than the one used in the Query component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateQuery shouldn't be a prop of the Query component. It's only a property of the config o ject passed to fetchMore
Good point, I've updated the PR to reflect that.
Oh yeah, I just noticed that It is closer to working now. The query executes but my combine function has some issue. Something is coming through as non-optional that I'm expecting to be optional. I'll keep plugging away. |
I'm pretty much stuck here. I can't get the typing to work out: The updateQuery function doesn't actually take Any ideas? |
With the last commit, this "sort of" works. The function I pass in to
Where It's not quite ideal but it works. Any suggestions on a better way would be appreciated. |
src/ReasonApolloTypes.re
Outdated
@@ -8,7 +8,7 @@ type queryString; | |||
* query string to the standard GraphQL AST. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there are no actual changes in this file, just refmt, it should probably not be in this PR.
@@ -8,6 +8,23 @@ module Get = (Config: ReasonApolloTypes.Config) => { | |||
| Loading | |||
| Error(apolloError) | |||
| Data(Config.t); | |||
type updateQueryOptions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change this to
[@bs.deriving abstract]
type updateQueryOptions = {
fetchMoreResult: option(Js.Json.t),
variables: Js.Json.t,
};
you can remove the next type declaration as they are then the same.
And you can simplify the switch at line 122 to:
switch (updateQuery) {
| Some(updateQuery) =>
Some(
(
(previousResult, opts) => updateQuery(previousResult, opts)
),
)
| None => None
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems to have a small side effect. In the application code that is using this: opts##fetchMoreResult is no longer optional. It seems like it should be based on: https://www.apollographql.com/docs/react/features/pagination.html#numbered-pages shouldn't it?
I think I've gotten the types sorted out here with the help of @ulrikstrid . Anyone else have any comments on this PR? |
Any thoughts on getting this merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👌
I added a commit containing:
If you see any error, please comment! I'm going to open a request in graphql_ppx, because |
@Gregoirevda I'm trying to update my application code to support these changes. I'm not sure about the use of
The first argument isn't a |
Any update on this? |
[@bs.deriving abstract] | ||
type updateQueryOptions = { | ||
[@bs.optional] | ||
fetchMoreResult: Config.t, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about fetchMoreResult? It should be a Js.Json.t no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe so.
I asked for a feature in graphql_ppx for __typename fields support. This is related to this issue. |
Sorry for taking so long. I made the |
Just tested this out on master, works great. Thanks! |
I could just not post a new big example project yesterday evening, will push asap |
Can someone post how to make the reason-apollo swapi example actually update Apollo Store? Right now there is just a placeholder for it:
I see here in the apollo docs that the js version looks like this:
This kinda works but it is not handling the
|
updateQuery for fetchMore
Pull Request Labels
fixes #79
This sort of works but the solution doesn't seem ideal. I'm posting it now to get some feedback. Does this seem like a reasonable approach?
Also, I plan to squash the PR once the solution seems agreed upon, but I would like to keep some of my past implementations for the time being until a solution is settled upon.