torchbox / wagtail-grapple

A Wagtail app that makes building GraphQL endpoints a breeze!
https://wagtail-grapple.readthedocs.io/en/latest/
Other
153 stars 57 forks source link

Consolidate handling when resolving Sites and avoid making assumptions about what data to return when it's ambiguous #342

Closed kbayliss closed 1 year ago

kbayliss commented 1 year ago

https://github.com/torchbox/wagtail-grapple/issues/340 identifies that the handling of resolving sites is inconsistent depending on the context.

This MR addresses that so that:

  1. A GraphQLError is no longer raised if querying for a Site with a hostname that doesn't exist (as this is an expected error) - similar to what already happens when querying for a Site by ID that doesn't exist
  2. Consolidates the handling of site resolving to reduce code
  3. We no longer return Pages for the first Site when querying for Pages with an erroneous Site filter (i.e. providing a hostname=does.not.exist query filter should not return Pages for the first Site - it should return None).
  4. We no longer return SiteSettings for the first Site when querying for SiteSettings without a site filter when there are multiple Sites.

Also, I had to remove a migration dependency for taggit when initialising an empty database - I didn't look into why, though I did confirm that taggit migrations are still run as Wagtail requires 'em.