-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: markSubscriptionsStale is not a function #112
Comments
Looking at this more, I'm seeing other methods as undefined: Seems to have reference to the wrong service? |
@mdbiscan how are you trying to use Apollo? The recommended way is to import a query manager mixin and use that in your route/controller/component/etc: import Route from "@ember/routing/route";
import RouteQueryManager from "ember-apollo-client/mixins/route-query-manager";
import query from "my-app/gql/queries/human";
export default Route.extend(RouteQueryManager, {
model(params) {
let variables = { id: params.id };
return this.get("apollo").watchQuery({ query, variables }, "human");
}
}); Though I just realized the readme has some spots that use |
This was my original route: import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import RouteQueryManager from 'ember-apollo-client/mixins/route-query-manager';
import query from 'ember-apollo-example/gql/queries/allAuthors';
export default Route.extend(RouteQueryManager, {
apollo: service(),
model(params) {
return this.get('apollo')
.query({ query }, 'author')
.catch(error => console.error(`Authors Route: ${error}`));
},
}); This will return the original error. I switched to the following code: import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import RouteQueryManager from 'ember-apollo-client/mixins/route-query-manager';
import query from 'ember-apollo-example/gql/queries/allAuthors';
export default Route.extend(RouteQueryManager, {
apollo: service(),
model(params) {
const variables = { id: params.id };
return this.get('apollo')
.watchQuery({ query, variables }, 'author')
.catch(error => console.error(`Authors Route: ${error}`));
},
}); However, I still get the same error whether or not I use One last thing: Removing the mixin (just to get the request going), in my network tab, I definitely get a query returned with no errors. However, the model being returned is always |
Ah, I see the issue. By including the apollo service directly, you’re actually overriding the apollo query manager. The fix is to only use the mixin and not the service injection. |
OK, that makes sense now that you point it out. I'm doing this now: import Route from '@ember/routing/route';
import RouteQueryManager from 'ember-apollo-client/mixins/route-query-manager';
import query from 'ember-apollo-example/gql/queries/allAuthors';
export default Route.extend(RouteQueryManager, {
model(params) {
const variables = { id: params.id };
return this.get('apollo')
.watchQuery({ query, variables }, 'author')
.catch(error => console.error(`Authors Route: ${error}`));
},
}); Getting this error: |
Interestingly, I changed back to |
Have you tried to replace |
Ah, that worked. Not sure how it muddled everything. |
Yeah, that's a known issue. If your query doesn't return any data then there's nothing for us to |
Ah, well that's good to know. Thanks again for the help! |
I keep getting this error trying to use this package:
Error while processing route: authors this.get(...).markSubscriptionsStale is not a function
Found on line 9 of
route-query-manager.js
referencingthis.get('apollo')
:The text was updated successfully, but these errors were encountered: