0
refetchQueries
が機能しなくなりました。アポロでrefetchQueriesを使用して反応します
「物を追加する」というフォームがありますが、「物のリスト」に戻ると、新しく作成された物はページを更新するときにのみ表示されます。 (中間ステップとして)私は、成功した "追加"の後に物事のリストを更新したいと思います。
私は以下を試みましたが、うまくいきませんでした。 docsは非常に簡単ですので、私は、私は、単純な何か欠けている必要がありますように感じるんだ:
// Called successfully
const updateThing = gql`
mutation AddThing($id: ID, $title: String!) {
problem(id: $id, title: $title) {
id
title
}
}
// NOT CALLED :(
const listThings = gql`
query ListThings($includeArchived: Boolean = false) {
problems(includeArchived: $includeArchived) {
id,
archived
}
}
// Form (simplified version of Formik form)
const ThingForm = props => (
<form onSubmit={e=> {
e.preventDefault();
e.handleSave({
variables: {
title: 'test'
}
})
}}
>
<button type="submit">Add thing</button>
</form>
)
// Connect
export const ThingAdd = compose(
graphql(
updateThing,
{
name: 'handleSave',
options: ({values}) => ({...values }),
refetchQueries: [{
query: listThing,
variables: ({includeArchived: true})
}]
}
)
)(
ThingForm
);
を関連DEPS:
"apollo-cache-inmemory": "^1.1.0",
"apollo-client": "^2.0.2",
"apollo-fetch": "^0.6.0",
"apollo-link-core": "^0.5.4",
"apollo-link-http": "^1.1.0",
"graphql": "0.10.5",
"graphql-tag": "^2.5.0",
"graphql-tools": "^2.7.2",
"react": "^16.0.0",
"react-apollo": "^2.0.0",