-
Notifications
You must be signed in to change notification settings - Fork 14
Description
What problem does this address?
As a developer building headless sites and applications with WPGraphQL and Advanced Custom Fields, I would like to be able to mutate ACF data using GraphQL Mutations.
What is your proposed solution?
Similar to how ACF Field Groups and Fields are exposed to the Schema as Types and Fields that can be queried, the field groups and fields should also be exposed to the Schema as Input Types and associated with the corresponding mutations (createPost
, etc)
What alternatives have you considered?
- not supporting this feature
- allowing users to hook/filter in their own support
- let the community maintain solutions (ex: https://github.com/zngly/wp-graphql-acf-mutations)
Additional Context
This issue is currently considered blocked for the following reasons:
Access Control
We believe there needs to be a lot more work on the core ACF side to define access control. What fields can be edited by what users (which capabilities, etc)
Of course, WPGraphQL could solve this to some degree, but we believe it's a more central issue as fields could be edited in the admin UI, CLI, REST, GraphQL, etc, so core ACF should provide more ways to formally lock down which fields can/cannot be modified by certain users.
GraphQL oneOf Directive / Input Unions
GraphQL has the concept of Unions and Interfaces for queries, which allows the response to return "one of" many possible types.
For example, we can query contentNode
and get "one of" the many Types that represent a WordPress Post Type (Page, Post, etc)
Or we can query nodeByUri()
and get "one of" the many possible Types that can be accessed by a uri (Post, Page, User, Category, Tag, etc)
When it comes to inputting data, GraphQL does not (yet) support the concept of inputting "one of" many different possible types.
This is a critical feature, in our mind, to be able to properly support mutations for ACF because the Types of data that can be input could easily be "one of" many different Types. Especially, but certainly not limited to, when inputting data for field Types such as Flexible Content would be needed.
The GraphQL Spec currently has an RFC open for this concept: graphql/graphql-spec#825
Until this feature becomes part of the GraphQL Spec ,and then GraphQL-PHP, and then WPGraphQL, we will not be officially supporting GraphQL mutations for ACF.