Skip to content

Conversation

@jgfidelis
Copy link
Owner

Refetch container working but replacing all items instead of appending. New items should be added to end of list. Is it possible with refetch container?


const fetchQuery = async (operation, variables, cacheConfig, uploadables) => {
const response = await fetch('https://graphql-sw-api-klmkpknwdl.now.sh/', {
const response = await fetch('https://graphql-sw-api-gxmdjgcfhi.now.sh/', {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can create an alias, so you don't need to update this every time you deploy to server \o/

<FlatList
data={peoplePage}
renderItem={this.renderItem}
keyExtractor={item => item.name}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it's better to use an id here

page: { type: "Int", defaultValue: 1 }
) {
peoplePage(page: $page) {
name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can ask for id here

@jgcmarins
Copy link

cc @lXSPandora


this.props.relay.refetch(
refetchVariables,
null,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing renderVariables here
see this: https://facebook.github.io/relay/docs/en/refetch-container.html#arguments
its buggy, so search for renderVariables

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then add here:

renderVariables,

if (isFetchingEnd === true) return;

if (page > 9) return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add here:

const total = page + 1;


this.setState({
isFetchingEnd: true,
page: page + 1,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

page: total,

...fragmentVariables,
page: page + 1
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const renderVariables = {
  page: total,
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants