mirror of
https://github.com/wassname/talk.git
synced 2026-06-30 04:20:14 +08:00
Merge pull request #905 from coralproject/fix-query-event-names
Use correct event name in queries
This commit is contained in:
@@ -69,7 +69,7 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => {
|
||||
const status = networkStatusToString(networkStatus);
|
||||
|
||||
const {root} = separateDataAndRoot(data);
|
||||
this.context.eventEmitter.emit(`query.${name}.${status}`, {variables, data: root});
|
||||
this.context.eventEmitter.emit(`query.${this.name}.${status}`, {variables, data: root});
|
||||
}
|
||||
|
||||
nextData(data) {
|
||||
@@ -121,7 +121,7 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => {
|
||||
const resolvedDocument = this.resolveDocument(lmArgs.query);
|
||||
const fetchName = getDefinitionName(resolvedDocument);
|
||||
this.context.eventEmitter.emit(
|
||||
`query.${name}.fetchMore.${fetchName}.begin`,
|
||||
`query.${this.name}.fetchMore.${fetchName}.begin`,
|
||||
{variables: lmArgs.variables});
|
||||
|
||||
// Resolve document fragments before passing it to `apollo-client`.
|
||||
@@ -131,13 +131,13 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => {
|
||||
})
|
||||
.then((res) => {
|
||||
this.context.eventEmitter.emit(
|
||||
`query.${name}.fetchMore.${fetchName}.success`,
|
||||
`query.${this.name}.fetchMore.${fetchName}.success`,
|
||||
{variables: lmArgs.variables, data: res.data});
|
||||
return Promise.resolve(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
this.context.eventEmitter.emit(
|
||||
`query.${name}.fetchMore.${fetchName}.error`,
|
||||
`query.${this.name}.fetchMore.${fetchName}.error`,
|
||||
{variables: lmArgs.variables, error: err});
|
||||
throw err;
|
||||
});
|
||||
@@ -168,7 +168,7 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => {
|
||||
const base = (typeof this.wrappedConfig.options === 'function')
|
||||
? this.wrappedConfig.options(data)
|
||||
: this.wrappedConfig.options;
|
||||
const configs = this.graphqlRegistry.getQueryOptions(name);
|
||||
const configs = this.graphqlRegistry.getQueryOptions(this.name);
|
||||
const reducerCallbacks =
|
||||
[base.reducer || ((i) => i)]
|
||||
.concat(...configs.map((cfg) => cfg.reducer))
|
||||
|
||||
Reference in New Issue
Block a user