Closed Twisterking closed 4 years ago
const SUBSCRIBE_USERS = gql`
subscription($limit: Int, $skip: Int) {
lists(limit: $limit, skip: $skip) {
event
doc
}
}
`
Use it without nested fields, just doc
Thank you @theodorDiaconu!
Now I have a new error:
TypeError: observable.observeChanges is not a function
in this line:
Subscription: {
lists: {
resolve: payload => payload,
subscribe(_, {limit, skip}, { db }, ast) {
const observer = db.listsbody.astToQuery(ast, {
$options: { limit, skip }
});
return asyncIterator(observer); // THIS LINE //
}
}
}
Maybe I can't use astToQuery()
in a subscription?!
@Twisterking because it's done on a mongo cursor, not a query. db.listsbody.find()
is a cursor.
Okay it kinda works now. Unfortunately the subscriptions don't update the data on the client. I already tried this:
<ReactiveQuery
query={GET_USERS}
variables={{listId: "pshLYD4optX3yj9Pw", limit: 20, skip: (page-1)*20}}
subscription={SUBSCRIBE_USERS}
fetchPolicy='no-cache'
>
no change! 😢
One more thing: Since you said that I don't need to define any subfields in the doc
in my Subscription
, why do you have it like this in your Readme?
@Twisterking you'll have to create repro for me.
So I am very new to Apollo/GraphQL in general, so please bear with me:
My :
my
typeDefs
on the server look something like this:... any my Subscription resolver:
After some time always the same Error pops up:
I guess I am missing something here I just can't see right now with my not existing GraphQL experience. 😄 Hope someone can help, thanks!