wp-graphql / wp-graphql/wpgraphql-acf

Add Validation to GraphQL Fields on ACF Field Group Pages

Open
#87 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: actionable type: enhancement
Dominant language
PHP
Stars
110
Forks
18
PR merge metrics
No merged PRs in 30d

Description

What problem does this address?

ACF didn't support validation of fields on the ACF Field Group pages until very recently (I believe v6.1 or 6.2, perhaps)

Because of that, we added fields without validation.

Ideally, fields such as "graphql_field_name" would be validated during creation of an ACF Field Group, ensuring that duplicate Types are not being added to the schema, etc.

What is your proposed solution?

The following validation should occur when using the ACF UI to create ACF Field Groups:

ACF Field Group
  • graphql_type_name:

    • The type name should be unique across the schema. ex, can’t add a “Post” type as a GraphQL field group as that already exists.
    • Type Names can’t start with numbers
    • Type Names can’t have special characters
    • Type Names can’t start with a double underscore
    • Changing the name might result in a breaking change
  • show_in_graphql:

    • changing this value from true to false should warn the user that removing field groups might be a breaking
      change
ACF Field:
  • graphql_field_name:

    • The field name should be unique, not existing as another field name on the Type(s) the Field Group will be added to
    • Field name cannot start with a number
    • Field name cannot have special characters
    • Changing the “graphql_field_name” could result in a breaking change to the Schema
  • show_in_graphql:

    • changing this value from true to false should warn the user that removing field groups might be a breaking change
What alternatives have you considered?

Not validating fields during field creation and letting folks find out the hard way that their Schema is broken, etc.

😱 😭

Additional Context

Because ACF fields and field groups have the ability to modify the GraphQL Schema, and therefore could cause direct problems to decoupled applications using the Schema, I believe we're doing a disservice to not provide proper validation before letting new field groups be created.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the ACF Field Group and ACF Field UI creation flows described in the issue, then trace how their values affect the GraphQL schema. Done should include validation for names, uniqueness, and invalid characters, plus warnings for schema-breaking changes when names or visibility are changed.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, php
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.