cult-of-coders / grapher-react

Provides easy to use React Components that are suitable for grapher package.
https://atmospherejs.com/cultofcoders/grapher-react
38 stars 19 forks source link

Difficulty understanding reactive named queries and links #12

Closed unoriginalscreenname closed 7 years ago

unoriginalscreenname commented 7 years ago

I'm really impressed with this whole library, but i'm having a little trouble understanding reactive queries with grapher-react.

I create a named query 'postsAll', which pulls from the 'posts' collection and has a link setup to 'author'. I export that query, and return it inside 'withQuery' on the client side, specifying {reactive:true}

I get an error saying that i need to expose the query. so I add a 'postsAll.expose()' on the server, which now makes the query reactive! However, it doesn't pull in the linked fields... so i don't get the author information. However, if i turn reactive:false, that linked field is included.

I don't think there is an issue on your side, but i think i'm having trouble following the documentation here. I didn't expect that the reactive feature would disable the collection linking. is this the case?

There are also several different types of queries you can create... i understand what they do, but it's a little hard to follow when you should use named vs regular and how the exposure options affect those queries vs an entire collection.

Apologies if i'm missing something basic. Just found this and i'm super excited to really understand it and get it working.

theodorDiaconu commented 7 years ago

@ericmcgregor https://github.com/cult-of-coders/grapher/blob/master/docs/structure_and_patterns.md

If your link is not working and it should, most likely you did not import it in your environment

This is one of the most common problems people have initially with Grapher, we've put it in the documentation, but maybe we need to make it more evident ?

unoriginalscreenname commented 7 years ago

Oh, you're right! I had followed the file structure outlined there, but i didn't import the /imports/db/index.js file on the client. thanks.