madebyraygun / trending-posts

Trending Posts for Craft CMS 3 tracks pageviews over time and orders posts by popularity on the front-end.
MIT License
6 stars 3 forks source link

GraphQL Support #12

Open codyjames opened 4 years ago

codyjames commented 4 years ago

I'd love to use this for a GraphQL-based site. Not sure how it'd work, but it'd be useful!

daltonrooney commented 4 years ago

Are you thinking of sorting by popularity in GraphQL queries, or somehow triggering page views in a GraphQL mutation as well?

I haven't dug too deeply into the GraphQL internals yet but it seems like it should be possible, especially with the changes coming in 3.4. I think the P&T team is going to put some additional work into the documentation for extending GraphQL also.

Just curious, have you tried orderBy('popular') in a GraphQL query yet? Who knows, maybe it just works.

codyjames commented 4 years ago

Thanks for the quick reply. Yeah, we'd need it to trigger the page views as a GraphQL mutation. The one issue I see is that the currently the GraphQL cache is invalidated every time an entry is updated. So, if this updates the entry, then it'd render the cache useless, which wouldn't be good.

I'm looking forward to more GraphQL docs and things from the Craft team.

codyjames commented 4 years ago

Oops, I accidentally closed this! Sorry!