Skip to content

Autogenerate facets as connection where args #31

@justlevine

Description

@justlevine

What problem does this address?

Currently to use this plugin, you need to manually register_graphql_facet_type(), and then query the facet from RootQuery.
That's a lot of manual work for the user, as well as more verbose queries.

What is your proposed solution?

We should be able to use the existing FacetWP data to autoregister facets to the schema out of the box, ideally as an input on the connections's {Type}ConnectionWhereArgs.

Similarly, facet data can be added to the connection edge.

E.g.

query GetPosts($query: FacetQueryArgs, $after: String, $search: String, $orderBy: [PostObjectsConnectionOrderbyInput]) {
  posts(first: 10, after: $after, where: {status: PUBLISH, search: $search, orderby: $orderBy, facetQuery: $query }) {
    pageInfo {
      hasNextPage
      endCursor
    }
    selectedFacet {
      name
      label
      choices {
        value
        label
        count
      }
    }
    nodes {
      title
      excerpt
    }
  }
}

What alternatives have you considered?

No response

Additional Context

This would be a non-breaking enhancement

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions