Skip to content

Conversation

@justlevine
Copy link
Collaborator

@justlevine justlevine commented Apr 11, 2024

What does this implement/fix? Explain your changes.

This PR introduces the new Experiments API, allowing us to begin working/iterating on on experimental features within WPGraphQL core without worrying about future compatibility.

How it Works.

  1. Individual experiments are implemented by extending the WPGraphQL\Experimental\Experiment\AbstractExperiment class.
  2. These classes are initialized by the WPGraphQL\Experimental\ExperimentRegistry, and their functionality loaded (by calling AbstractExperiment::init() ) only if the experiment is active.
  3. Users can toggle experiments from the WPGraphQL Settings > Experiments tab, or programmatically with the GRAPHQL_EXPERIMENTAL_FEATURES constant.

More details in src/Experimental/README.md

Tasks

  • Scaffold API
  • Create example Experiment.
  • Review and improve Admin UI
  • Implement tests
  • Add usage/developer docs

Does this close any currently open issues?

Part of #3081

Any relevant logs, error output, GraphiQL screenshots, etc?

  1. Experiments Tab

Note

This screen recycles existing Settings API field types.
To improve the UX we may want to introduce a new field type callback.

image

  1. When active, the new field is added to the schema

image

Any other comments?

Where has this been tested?

Operating System: Ubuntu 20.04 (wsl2+ devilbox + php 8.1.15)

WordPress Version: 6.5.2

@justlevine justlevine added status: in progress Currently being worked on type: feature New functionality being added scope: api Issues related to access functions, actions, and filters labels Apr 11, 2024
@coveralls
Copy link

coveralls commented Apr 11, 2024

Coverage Status

coverage: 83.578% (-1.0%) from 84.575%
when pulling 6187a2b on justlevine:feat/experiments-api
into 67f0d7b on wp-graphql:develop.

@jasonbahl
Copy link
Collaborator

@justlevine I like where this is going. Will try and look at it more detailed shortly, but very nice idea

@justlevine
Copy link
Collaborator Author

@jasonbahl this is very early work, I'll ping you when it's worth your time to look over for real

@justlevine justlevine force-pushed the feat/experiments-api branch from 9245c75 to fec4324 Compare April 25, 2024 16:16
@justlevine justlevine force-pushed the feat/experiments-api branch from 269ff74 to c5ec8ed Compare April 27, 2024 18:40
@justlevine justlevine added needs: discussion Requires a discussion to proceed needs: reviewer response This needs the attention of a codeowner or maintainer and removed status: in progress Currently being worked on labels Apr 27, 2024
@justlevine
Copy link
Collaborator Author

justlevine commented Apr 27, 2024

@jasonbahl this is ready for initial review.

  • Ideally the Admin UX would be improved, but that will require a new Settings API field type callback.
  • Waiting to have feedback before tests get implemented.
  • The TestExperiment is super barebones, but considering you can do pretty much whatever you want inside ChildExperiment::init(), i'm not entirely sure if we need anything else.

/**
* Prepares the configuration.
*
* @return array{title:string,description:string}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using phpstan now?

Copy link
Collaborator Author

@justlevine justlevine Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've been using it for a while. I'll probably unseal the type before final merge, but for now it makes sure nothing unnecessary is leaking in to the PR

*/
protected function is_enabled(): bool {
if ( ! isset( $this->is_enabled ) ) {
$this->is_enabled = defined( 'GRAPHQL_EXPERIMENTAL_FEATURES' ) ? (bool) GRAPHQL_EXPERIMENTAL_FEATURES : true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any custom tab in the Site Health screen/page? Might help with debugging.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, but it was mentioned in the last Office Hours 🤞


return [];
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if multiple experiments are registered with the same slug we should call that out.

When testing the API, I accidentally left the slug the same as the test experiement, and my new one showed up but the test one disappeared and it took me a second to realize that it was because I left the slug the same. I caught it quickly, but would have caught it quicker if something warned me about the duplicate slugs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonbahlon re-review, I'm not entirely sure where to implement this, if at all.

As the initial release only targets usage by the core plugin, the register_experiments() relies on a hard-coded map, so issues like this would best be caught by code review.

We could refactor so each Experiment "registers itself" instead of using a class-map, but imo that's unnecessary complexity at this stage.

Thoughts?

@jasonbahl
Copy link
Collaborator

@justlevine What is the difference between an "Experiment" and a "Feature Plugin"?

In both cases I have the option to activate / deactivate some functionality. But the difference is that experiments are now bundled in core WPGraphQL where feature plugins (i.e. WPGraphQL Smart Cache, etc) can be versioned, updated, rolled-back, etc separate from WPGraphQL core.

I'm curious what you believe the scope of an "Experiment" should be and how it is different than another plugin that can be installed and activated?

Some examples of possible experiments that come to my mind might be:

  • "Offset Pagination": letting users opt-in to page-based pagination instead of (or alongside) cursor pagination
  • "Custom Scalars": Enable certain custom scalars and/or associate them with certain fields
  • "Activity Tracking": WPGraphQL Smart Cache has "activity tracking" (similar to WPGatsby) that pays attention to events in WordPress and centralizes when to emit a "purge" action. I could see this functionality coming to core WordPress and maybe enabled via an Experiment while we polish things?

I don't actually know how to justify bundling these in core as an experiment vs. shipping them as a separate plugin that folks can "enable" via installing and activating the plugin 🤔

@renatonascalves
Copy link
Collaborator

I think the main difference from a feature plugin is that you can activate a feature per request, per part of the site. Similar to this plugin.

Instead of deactivating the whole plugin. Experiment here, to me, is similar to an A/B test feature. I need both code to be available/active but I can choose to use one at a time or at the same time per request/page/etc.

@jasonbahl
Copy link
Collaborator

I think the main difference from a feature plugin is that you can activate a feature per request, per part of the site. Similar to this plugin.

What do you mean "per request"? I read that as per http request. Like one query might have the feature enabled and one query might not? Or something like that? Does the HTTP request have to identify that it wants to use said experiment via query parameter or something?

I guess I'm not fully following

@jasonbahl
Copy link
Collaborator

jasonbahl commented May 8, 2024

@renatonascalves looking at the plugin you shared from Alley, I'm still not sure how that differs from activating/de-activating a plugin. The user experience is still:

while logged in to the WordPress admin as an administrator (or a user with the manage_options capability) you can turn feature flags on and off via a simple checkbox interface

That sounds just like the user experience of navigating to the plugins page and using a checkbox interface to activate a plugin.

I think I need some more concrete examples and use cases of where this makes sense and adds value that an extension plugin doesn't make sense or doesn't add the same value?

It's clear there are use cases, but I'm struggling to see them

@renatonascalves
Copy link
Collaborator

I think I'll leave for @justlevine to explain it since it is his feature. But I understood the feature as something that could be toggled on and off easily and used or not per request/page/location (but that is more about how the feature could be used rather than the intention of the feature).

@jasonbahl
Copy link
Collaborator

From @justlevine:

End user statement:

"WPGraphQL Experiments allow you to experience the future of WPGraphQL today".

Purpose:

Allow for the shipping, iterating, and gathering feedback on (potential) upcoming changes to WPGraphQL core.

What makes a good experiment:

  • limited in scope
  • changes or enhances fundamental behavior of WPGraphQL core
  • is greenlit as a core feature on a roadmap level, but would either be a breaking change to implement, or needs more feedback about whether it's actually helpful for the bulk of our users/iteration before it can be recommended in production.
  • can be supported by maintainers.

What makes a bad experiment:

  • Features that only benefit a small subset of users (e.g. WP plugin interop)
  • Features that we aren't planning to implement into core (e.g. offset pagination)
  • Features that require more than just iteration before they can be considered usable in production.
  • Large complex features that would develop better in an isolated environment.
  • Features that are ready on our side, but require ecosystem adoption to prevent breaking changes downstream (e.g. Blocks)
  • Features we're unable unwilling to actively maintain.

Real world triage:

  • custom scalars > experiment
  • @OneOf directive / input rewrite > experiment
  • GraphiQL 2.0 > experiment
  • Offset Pagination > plugin
  • ACF > Plugin
  • Smart Cache > probably plugin with parts in core, but it's a bit gray
  • Gutenberg > experiment
  • Tax Query > experiment if this is something you eventually want to support in core, otherwise plugin.
  • Widgets/Sidebars > experiments if we want to see if people actually use this enough to include in core.

@jasonbahl
Copy link
Collaborator

@justlevine how would we migrate an experiment to production or deprecate an experiment we believe was a mistake?

@justlevine
Copy link
Collaborator Author

justlevine commented May 8, 2024

To tl;dr my above notes:

  1. Experiments are future flags, not feature flags. They allow us to work on greenlit features/enhancements for WPGraphQL core that for a myriad of possible considerations (breaking changes, ecosystem conficts, needs feedback/polish to make it forward-compatible/work at scale) aren't ready for mass adoption.
    Experiments are supported and maintained in their current version, but there is no guarantee of back/forward-compatibility. Similarly, they may be removed without notice.

  2. Features that service a small subset of users or provide an alternative to WPGraphQL core behavior are Plugin Extensions. Support and development of those Extensions are offered by those extensions.

  3. Feature Plugins are philosophically similar to Experiments, but practically similar to Extensions. Before this API we had no choice but to iterate outside of WPGraphQL core. With the API, there are fewer good candidates for a separate Feature Plugin, which likely that meet a combination of the following criteria:

    • A feature that is currently at the "idea phase" and not MVP-complete
    • A feature that would benefit from independent iteration and testing outside of the traditional WPGraphQL cadence.
    • A feature that we're unable/unwilling to provide the same level of support for as WPGraphQL core code at its current stage of development.
    • A feature that needs a project-level decision on whether to greenlight something for core.

With the above context some replies:

@jasonbahl

"Offset Pagination": letting users opt-in to page-based pagination instead of (or alongside) cursor pagination
❌ It's an alternative experience for a subset of users and one we don't plan to actively support. If in the future we wanted to allow all users to paginate by either offset or cursor, then we could Experiment in core until we're ready to ship the API publicly.

"Custom Scalars": Enable certain custom scalars and/or associate them with certain fields
✔️ Including them means both us and 3rd pary plugins can start building on them before we're ready to break the entire schema by turning them on publicly.

"Activity Tracking": WPGraphQL Smart Cache has "activity tracking" (similar to WPGatsby) that pays attention to events in WordPress and centralizes when to emit a "purge" action. I could see this functionality coming to core WordPress and maybe enabled via an Experiment while we polish things?
✔️ While parts of Smart Cache make sense to stay in the plugin, an Activity Tracking API is indeed a good candidate for core adoption (applies to the entire eco, greenlit by @jasonbahl , etc). Plugins like Smart Cache would force-enable the Experiment, and then build around it like other core WPGraphQL features.

I don't actually know how to justify bundling these in core as an experiment vs. shipping them as a separate plugin that folks can "enable" via installing and activating the plugin 🤔

With the above clarification between feature plugin and extension, the justification is reversed and usually clearer. Experiment for core changes, Plugin Extension for alternative behavior that doesn't meet the 80/20 rule, Feature Plugin when practical concerns about support/development justify the extra complexity for both developers and users (who need to find out about and install the plugin before they can activate it).

@renatonascalves

I think the main difference from a feature plugin is that you can activate a feature per request, per part of the site. Similar to this plugin.

Instead of deactivating the whole plugin. Experiment here, to me, is similar to an A/B test feature. I need both code to be available/active but I can choose to use one at a time or at the same time per request/page/etc.

[...] I understood the feature as something that could be toggled on and off easily and used or not per request/page/location

Similar but not exactly. I think I addressed most of this already so tl;dr for now, but happy to expand if needed:

  • As mentioned, future flags are not feature flags. The goal is to use them to iterate more quickly on WPGraphQL core functionality.
  • While there is a benefit to the user of being able to easily toggle a feature on/off without having to install/activate a separate plugin, that's more of a happy side effect. The intent is to be able to test, iterate, and allow extensions/end users to opt into functionality with significantly less overhead.
  • Experiments could be used for A/B testing, but from a WPGraphQL core perspective: E.g. a totally new DataLoader that we want to make sure has performance parity with the existing DataLoader. They are not intended to allow for different requests to behave differently IRL.

Moving on from use case to implementation:

@jasonbahl

how would we migrate an experiment to production or deprecate an experiment we believe was a mistake?

I havn't implemented this into the code yet, but per my mental model:

  • Experiment Graduation:

    1. we relocate the code outside of experiments into the actual Core classes.
    2. (optional) we display a dismissible admin notice letting a user know when an activated Experiment has graduated.
    3. we display a (dismissible?) admin notice letting a user know they no longer need to include the experiment slug in the constant, if they're programmatically activating the experiment.
    4. We update the Admin UX to grey out the toggle and say the experiment is graduated. We remove the experiment from the list altogether in the next breaking release.
  • Experiment Deprecation/Removal

    1. If/when deprecated, a dismissable admin notice warning about the impending remove will appear every X days.
    2. When removed, a permanent admin notice warns that the experiment has been removed for those who had it it activated before update or those who are programmatically activating it.
    3. We update the admin UX to grey out the toggle and say the experiment is no longer available. We remove the experiment from the list altogether in the next breaking release.
    4. (Optional) Depending on the Experiment, whims of the maintainers, or whatever we may drop the code into an extension or code snippet.
    5. (Based on parallel conversation with @jasonbahl on Discord): We check for removed active experiments during our future SemVer update checker (Idea: SemVer auto-update enforcement #2543)

@jasonbahl
Copy link
Collaborator

@justlevine how do consumers of the API know that they are consuming field(s) / Type(s) that are experimental?

For orgs / teams where there are different people/teams consuming the API and another person/team maintaining the WordPress install, it would be nice for a consumer of the API to know whether they are interacting with something experimental and/or explicitly ask to interact with an experimental version of the API or a stable version.

Hypothetical Scenario:

WP team enables an experimental feature xx.

Client team starts consuming xx.

Experiment is deprecated. An admin notice was displayed for the WordPress team, but the client team didn't know about the impending deprecation. Client app is now breaking.


Should we consider outputting something in the Extensions output of GraphQL queries to indicate active experiments? And/or allow the client to pass something in the request like:

graphql( [
  'query' => $query,
  'variables' => $variables,
  'extensions' => [
    'experimentsEnabled' => true/false // or something along those lines? 
  ]
] );

And/or the payload of a response could include something like:

{
  "data": {
    "someExperimentalField": "some data",
  },
  "extensions": {
    "enabledExperiments": [
      "experimentOne": {
        "description": "Description of the experiment and impact on the Schema / Resolution",
        "link": "https://github.com/wp-graphql/path/to/docs/about/the/experiment.md",
        "notes": "Maybe some notes such as impending deprecation date or impending core merge date or other?"
      }
    ]
  }
}

This would allow clients to have some insight into things that may/may not be around in the future, etc 🤔

@justlevine
Copy link
Collaborator Author

justlevine commented May 8, 2024

@jasonbahl I think a simple graphql_debug() notice on deprecation or removal would be a great idea: e.g.

The % Experiment has been deprecated and will be removed in v%. Please [migrate your code](change notice link) and deactivate the Experiment, or you will no longer be able to update WPGraphQL.

(More so, I think a graphql_debug() when WPGraphQL can't update bc of a compatibility issue would make a great addition to #2543 🤯)

Anything beyond that though feels like scope creep:

  • The frontend doesn't need debug data on active experiments, same as about any specific backend configuration setting. Schema is the source of truth and we can convey what's necessary_if anything_ via type name prefixes or descriptions, or even an empty Experimental interface, but I think the place to consider that is when we implement our first real experiment, and likely per experiment. There's a separate discussion to be had about exposing Site Health data, but imo that needs to happen holistically and away from the context of experiments.

  • More generally, I just don't believe the hypothetical scenario is a real user expectation. It's commonly understood that changing WordPress's configuration (deactivating a plugin, changing the url structure, removing a CPT, renaming an ACF field group) will alter the schema, and manually activating/deactivating an experiment is no different. And like all other WP configs they're not getting toggled much beyond initial setup . What we should be worried about is a change that isn't caused by user action, i.e. deprecation/removals/breaking updates. The grapql_debug() message covers that.

  • Exposing active experiments as a schema field however is additively useful. Possibly can be used to @skip (not sure offhand, I rarely need directives ), surely can be used in userland to conditionally use a different fragment or query in order to support both core and experimental behavior. This is a framework/library use case though, so I've left all the data exposure to be handled by graphql_register_setting() for now so we can focus on the consumer API first and then think about extension/framework implementations and repurposing in subsequent PRs. Easier to iterate w.o breaking changes this way IMO.

@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit adb5756 and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1

View more on Code Climate.

@justlevine
Copy link
Collaborator Author

@jasonbahl I think a simple graphql_debug() notice on deprecation or removal would be a great idea: e.g.

The % Experiment has been deprecated and will be removed in v%. Please [migrate your code](change notice link) and deactivate the Experiment, or you will no longer be able to update WPGraphQL.

(More so, I think a graphql_debug() when WPGraphQL can't update bc of a compatibility issue would make a great addition to #2543 🤯)

Anything beyond that though feels like scope creep:

Added deprecation handling in adb5756

@jasonbahl
Copy link
Collaborator

Some thoughts about the Experiments API after playing with implementing the WPGraphQL IDE as an experiment:

Admin Notification

It would be nice to have an admin notification informing users that new Experiment(s) are available to be activated.

If a new experiment is available (we'd likely need to store a list of experiments in the DB and diff against it in admin_init or something to that tune) then an admin notice (using register_graphql_admin_notice) could be displayed informing the user about the new experiment(s).

We should probably do the same when an experiment is removed, informing the users about the removal (de-activation / deprecation).

Experiment Activation / Deactivation Hook

Similar to when a plugin is activated / de-activated, experiments should be able to "do something" in response to being activated or de-activated.

For example, if I as an admin user activate the new WPGraphQL IDE Experiment, I would like to know what to do next.

If the experiment was able to do something like redirect to the IDE settings tab, or redirect to a custom IDE landing page or something, then users would know "what to do next"

Another (much simpler) option would be to just clarify the messaging in the Experiment description stating something to the tune of:

"After activating this experiment, do x,y and z" and "After de-activating this experiment to x,y and z"

^ That might mean we at least have some contextual messaging we should display on the experiments page. i.e. display x message if the experiment is active and y message if it's not active.

@jasonbahl jasonbahl added the needs: tests Tests should be added to be sure this works as expected label Jun 5, 2024
@jasonbahl jasonbahl mentioned this pull request Jan 30, 2025
5 tasks
@justlevine justlevine mentioned this pull request Jun 28, 2025
18 tasks
jasonbahl added a commit to jasonbahl/wp-graphql that referenced this pull request Oct 8, 2025
Implements the core Experiments API to enable rapid iteration on new features
before they're declared production-ready. This allows the community to test
and provide feedback on upcoming WPGraphQL features.

## Key Changes

### Core API Implementation
- Add `AbstractExperiment` base class for all experiments
- Add `ExperimentRegistry` to manage experiment registration and lifecycle
- Add `Experimental` class to initialize experimental functionality
- Add `Admin` class to integrate experiments into WPGraphQL Settings page
- Add `TestExperiment` as an example implementation

### Initialization & Timing
- Initialize experiments on `after_setup_theme` hook to prevent early translation loading
- Make `WPGraphQL::setup_experiments()` public for hook compatibility

### Experiment Activation Controls
- Support `GRAPHQL_EXPERIMENTAL_FEATURES` constant for programmatic control
  - `false` disables all experiments
  - Array format enables specific experiments: `['slug' => true]`
  - Constant overrides database settings
- Add `graphql_dangerously_override_experiments` filter to override constant behavior
  - Named to clearly indicate dangerous nature of bypassing hard-coded controls
  - Useful for testing and specific deployment scenarios

### Testing Infrastructure
- Add `ExperimentRegistryTest` with 2 tests covering registration and activation
- Add `AbstractExperimentTest` with 6 tests covering:
  - Config validation (title, description)
  - Slug retrieval
  - Deprecation methods
  - GRAPHQL_EXPERIMENTAL_FEATURES constant behavior (false & array)
  - Filter override functionality
- Add `clear_active_cache()` method to AbstractExperiment for testability
- Add `reload_experiments()` method to ExperimentRegistry for test isolation

### Code Quality
- Fix PHPStan error in `AppContext::get_loader()` return type
- Fix PHPStan error in `ExperimentRegistry` hook parameter type
- Update all `@since @todo` annotations to `@since next-version`
- Clean implementation without ReflectionClass usage in production code

## Related
- PR wp-graphql#3098
- Part of Phase 1.1 (Testing) from experiments-roadmap.md

## Testing
All 8 tests passing:
- 2 tests in ExperimentRegistryTest
- 6 tests in AbstractExperimentTest
- PHPStan analysis passes (1 pre-existing error in AppContext fixed)
jasonbahl added a commit to jasonbahl/wp-graphql that referenced this pull request Oct 9, 2025
Add complete documentation suite for the WPGraphQL Experiments API,
including four focused guides covering all user types and a Vision
section in README.md clarifying what belongs in core.

## Documentation Added

- docs/experiments.md (~166 lines)
  - What are experiments and why they exist
  - Experiments vs Extensions vs Feature Flags comparison
  - Experiment lifecycle with clear phases
  - Core principles and comprehensive FAQ

- docs/experiments-using.md (~393 lines)
  - End-user guide for enabling experiments
  - Multiple activation methods (Admin UI, wp-config, filters)
  - Environment-specific strategies (dev/staging/production)
  - Troubleshooting common issues and feedback guidelines

- docs/experiments-creating.md (~608 lines)
  - Step-by-step developer tutorial with fully-commented examples
  - Complete EmailAddress scalar implementation walkthrough
  - Testing patterns and best practices
  - Advanced patterns (dependencies, deprecation, graduation)
  - Common mistakes and debugging tips

- docs/experiments-contributing.md (~547 lines)
  - Contribution process from proposal to merge
  - Proposal template with detailed examples
  - Code review and iteration guidance
  - Graduation and deprecation processes
  - Tips for successful contributions

## Navigation & Structure

- Updated docs/docs_nav.json
  - Added dedicated "Experiments" section
  - Positioned between "Dig Deeper" and "Community"
  - All four docs linked and accessible

## README Updates

- Added Vision section (#vision anchor)
  - Clarifies WPGraphQL's role as canonical GraphQL API for WordPress
  - Defines what belongs in core vs extensions
  - NEW: Distinguishes experiments as "candidates for core" being validated
  - Explains experiments may graduate to core or be removed
  - Helps contributors understand appropriate scope for experiments

## Roadmap Updates

- Updated experiments-roadmap.md
  - Marked Phase 1.4 (Documentation) as complete
  - Listed all completed documentation files
  - Updated metrics and next steps

## Key Improvements

1. **Clarifies Experiments vs Extensions**: README Vision section now
   explicitly distinguishes experiments (potential core features being
   validated) from extensions (intentionally separate plugins)

2. **Complete Coverage**: Docs address three distinct audiences:
   - End users: How to enable and use experiments
   - Developers: How to create experiments
   - Contributors: How to propose experiments to core

3. **Practical Examples**: Every concept includes working code examples
   that can be copied and used immediately

4. **Cross-Referenced**: All docs link to related content, creating
   a cohesive documentation experience

## Acceptance Criteria Met

✅ Users can understand and enable experiments without asking questions
✅ Developers can build experiments following clear patterns
✅ Contributors understand the proposal-to-graduation process
✅ Vision section provides scope guidance for experiment proposals
✅ Documentation integrated into website navigation

Total: ~1,700 lines of new documentation

Related: wp-graphql#3098
jasonbahl added a commit to jasonbahl/wp-graphql that referenced this pull request Oct 9, 2025
Complete Phase 1.2 (Code Cleanup) by enhancing documentation and
ensuring code quality standards are met.

## Changes

### TestExperiment Documentation

Updated src/Experimental/Experiment/TestExperiment.php:

- Added comprehensive class-level documentation explaining purpose
- Clearly states it's a demonstration experiment for learning
- Documents what it does: adds a `testExperiment` field to RootQuery
- Includes example GraphQL query in docblock
- References documentation for real-world examples
- Serves triple purpose:
  * Working example for developers learning to create experiments
  * Test fixture for validating Experiments API
  * Harmless way for users to try enabling/disabling experiments

### ExperimentRegistry Documentation

Updated src/Experimental/ExperimentRegistry.php:

- Improved register_experiments() method documentation
- Added inline comment explaining TestExperiment's purpose
- Included code example showing how to register custom experiments
- Enhanced PHPDoc blocks for better developer experience

### Roadmap Updates

Updated experiments-roadmap.md:

- Marked Phase 1.2 (Code Cleanup) as complete ✅
- Documented all changes with date stamp
- Updated "Next Steps" section to reflect progress

## Testing

✅ All 861 tests passing
✅ PHPStan analysis: 0 errors
✅ No functionality changes, only documentation improvements

## Phase 1 Progress

- ✅ Phase 1.1 (Testing): Complete
- ✅ Phase 1.2 (Code Cleanup): Complete
- ⏸️ Phase 1.3 (Dependencies): Next
- ✅ Phase 1.4 (Documentation): Complete

## Next Steps

1. Verify CI/CD passes
2. Implement Experiment Dependencies (Phase 1.3)

Related: wp-graphql#3098
@jasonbahl
Copy link
Collaborator

@justlevine closing in favor of: #3428

@jasonbahl jasonbahl closed this Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs: discussion Requires a discussion to proceed needs: reviewer response This needs the attention of a codeowner or maintainer needs: tests Tests should be added to be sure this works as expected scope: api Issues related to access functions, actions, and filters type: feature New functionality being added

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants