verbb / comments

A Craft CMS plugin for managing comments directly within the CMS.
Other
137 stars 33 forks source link

Support GraphQL mutations #227

Closed mattstein closed 3 years ago

mattstein commented 3 years ago

Description

This PR-in-progress adds mutation support to approximate front-end controller actions via the GraphQL API.

There’s some architectural gray area—at least for me—since GraphQL includes a concept of customizable schemas and tokens, where a Craft User session may or may not be relevant or available depending on how the plugin is used. It seems like it’s best to support plugin settings wherever possible rather than duplicating them, keeping the schema components simple.

Comments are saved using SCENARIO_LIVE, mimicking Craft’s own elements+GraphQL. It seems like this scenario was previously unused and safe to set up exclusively for use via GraphQL.

This randomly adds a comment query for getting a single comment in addition to the existing comments one—mostly for fun and to follow the pattern used by first-party element types.

Features

GraphQL features to be supported and tested.

✓: supported and tested

Validation

Exhaustive list of settings to check against. (Some may already be supported and just need testing.)

✓: supported and tested

engram-design commented 3 years ago

Thanks so much for starting this @mattstein - amazing work! I'll review everything shortly.

mattstein commented 3 years ago

Sure thing @engram-design, just sneaking this draft PR in now that I’ve got a good start.

I noted quick examples of what’s working right now, but validation and schema components need fine-tuning to account for the plugin settings and user-limited actions. Still thinking through those a bit, but happy to talk through this at any point!

mattstein commented 3 years ago

Finally have this to a place that’s worth reviewing, @engram-design! Some interfaces may need adjustment (commentId instead of id, etc.), but I fleshed out the PR description for a better summary of what’s going on here.

engram-design commented 3 years ago

Nice work - I've been following along! I'll dive into review in the coming days.

engram-design commented 3 years ago

Thanks again for your work on this!