Comments (10)
Looking at this more, I'm seeing other methods as undefined: trackSubscription
, activeSubscriptions
, unsubscribeAll
.
Seems to have reference to the wrong service? mutate
, query
, and watchQuery
are all defined.
from ember-apollo-client.
@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.apollo
instead of this.get("apollo")
, which could potentially cause issues.
from ember-apollo-client.
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 query
or watchQuery
and whether or not I pass variables (which I am not, so they are null anyway).
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 undefined
. It's a promise, but undefined
when resolved. That has my head scratching...
from ember-apollo-client.
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.
from ember-apollo-client.
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: Uncaught TypeError: Cannot set property '_apolloObservable' of undefined
from ember-apollo-client.
Interestingly, I changed back to query
from watchQuery
, and receive no errors. However, the promise returns undefined
still.
from ember-apollo-client.
Have you tried to replace .watchQuery({ query, variables }, 'author')
to .watchQuery({ query, variables })
?
from ember-apollo-client.
Ah, that worked. Not sure how it muddled everything.
from ember-apollo-client.
Yeah, that's a known issue. If your query doesn't return any data then there's nothing for us to Ember.get
on. I'm not sure there's a good solution to it though without a big API change. Glad you got it working!
from ember-apollo-client.
Ah, well that's good to know. Thanks again for the help!
from ember-apollo-client.
Related Issues (20)
- Regression: Array is returned as object from resultKey on v3.0: HOT 1
- Subscription implementation questions HOT 2
- ember install ember-apollo-client broken
- ember-simple-auth example is out of date HOT 2
- Disable "Download the Apollo DevTools for a better development experience" warning HOT 2
- TS errors due to no react present HOT 1
- Cache is updating but computed property is not. HOT 2
- ReferenceError: react is not defined HOT 3
- Question: Ember Apollo Client and file uploads HOT 1
- Error using typescript HOT 1
- Can't build app due to dependencies placement in package.json
- Add a service override environment variable
- Build error when using Embroider HOT 3
- Update watchQuery results in the next runloop
- Could not find module `@apollo/client/core` imported from `ember-apollo-client/services/apollo` HOT 1
- Out of date client.
- @defer support HOT 1
- V4 service extension / v4 fails on ember 3.28 HOT 1
- Much bigger bundle size after upgrading @apollo/client HOT 1
- Define the types of the parameters from Apollo service's most used methods
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-apollo-client.