-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a failing test case for multiple model calls
As noted[1] by @viniciussbs, there's a flaw in this implementation. When `model()` is called twice on a route due to a query params change, all watchQuery subscriptions are cancelled, including the brand new one with the updated query params. Really we should only be cancelling the old queries that existed prior to the model reload. [1]: #20 (comment)
- Loading branch information
Showing
10 changed files
with
231 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Controller.extend({ | ||
queryParams: ['kind'], | ||
kind: null | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
query characters($kind: String!) { | ||
characters(kind: $kind) { | ||
... on Droid { | ||
id | ||
name | ||
} | ||
... on Human { | ||
id | ||
name | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Ember from 'ember'; | ||
import RouteQueryManager from 'ember-apollo-client/mixins/route-query-manager'; | ||
import query from 'dummy/gql/queries/characters'; | ||
|
||
const { inject: { service } } = Ember; | ||
|
||
export default Ember.Route.extend(RouteQueryManager, { | ||
apollo: service(), | ||
|
||
queryParams: { | ||
kind: { | ||
refreshModel: true | ||
} | ||
}, | ||
|
||
model(variables) { | ||
return this.apollo.watchQuery({ query, variables }, 'characters'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import ApolloService from "ember-apollo-client/services/apollo"; | ||
import Ember from "ember"; | ||
import { IntrospectionFragmentMatcher } from "apollo-client"; | ||
import TypeIntrospectionQuery from "dummy/utils/graphql-type-query"; | ||
|
||
const { computed, merge } = Ember; | ||
|
||
export default ApolloService.extend({ | ||
clientOptions: computed(function() { | ||
let opts = this._super(...arguments); | ||
return merge(opts, { | ||
fragmentMatcher: new IntrospectionFragmentMatcher({ | ||
introspectionQueryResultData: TypeIntrospectionQuery, | ||
}), | ||
}); | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<ul> | ||
{{#each model as |item|}} | ||
<li class='model-name'>{{item.name}}</li> | ||
{{/each}} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
export default { | ||
__schema: { | ||
types: [ | ||
{ | ||
kind: "UNION", | ||
name: "SearchResult", | ||
possibleTypes: [ | ||
{ | ||
name: "Droid", | ||
}, | ||
{ | ||
name: "Human", | ||
}, | ||
{ | ||
name: "Starship", | ||
}, | ||
], | ||
}, | ||
{ | ||
kind: "OBJECT", | ||
name: "Droid", | ||
possibleTypes: null, | ||
}, | ||
{ | ||
kind: "OBJECT", | ||
name: "Human", | ||
possibleTypes: null, | ||
}, | ||
{ | ||
kind: "OBJECT", | ||
name: "Starship", | ||
possibleTypes: null, | ||
}, | ||
{ | ||
kind: "OBJECT", | ||
name: "__Schema", | ||
possibleTypes: null, | ||
}, | ||
{ | ||
kind: "OBJECT", | ||
name: "__Type", | ||
possibleTypes: null, | ||
}, | ||
{ | ||
kind: "ENUM", | ||
name: "__TypeKind", | ||
possibleTypes: null, | ||
}, | ||
{ | ||
kind: "OBJECT", | ||
name: "__Field", | ||
possibleTypes: null, | ||
}, | ||
{ | ||
kind: "OBJECT", | ||
name: "__InputValue", | ||
possibleTypes: null, | ||
}, | ||
{ | ||
kind: "OBJECT", | ||
name: "__EnumValue", | ||
possibleTypes: null, | ||
}, | ||
{ | ||
kind: "OBJECT", | ||
name: "__Directive", | ||
possibleTypes: null, | ||
}, | ||
{ | ||
kind: "ENUM", | ||
name: "__DirectiveLocation", | ||
possibleTypes: null, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters