This repository was archived by the owner on Aug 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
CRUD and on Tables
Nicholas Romero edited this page Jul 30, 2017
·
2 revisions
So relay can build static queries first: 0 after: 0
export default createRefetchContainer(PollsList, {
viewer: graphql.experimental`
fragment Polls_viewer on Viewer
@argumentDefinitions(
first: {type: "Int", defaultValue: 0},
)
{
questions(first: $first){
edges {
node {
id
...Polls_question
}
}
}
}
`
},
graphql.experimental`
query PollsListRefetchQuery($first: Int) {
viewer{
...Polls_viewer @arguments(
first: $first,
)
}
}
`
);
Once the React component is finished mounting it will by default have isLoading: True in the state. It will then refetch with initial variables you specify. first: 10 after: 0
Once you are ready to refetch take the previous variables and update them.
class Component extends React.Component {
constructor(props) {
super(props)
this.state = {
isLoading: true,
variables: props.refetchVariables
}
}
onLoadCallBack(){
this.setState({ isLoading: false })
}
componentWillMount() {
this.props.relay.refetch(this.state.variables, null, this.onLoadCallBack())
}
Once a user change one of the defaults routers url should update
reango.com/polls/?first=10?after=0