You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat!: make #[EnumValue] control per-case enum schema exposure
Once any case of a #[Type]-mapped enum carries #[EnumValue], the enum enters
opt-in mode: only annotated cases are exposed and unannotated cases are hidden
from the schema. A fully-unannotated mapped enum stays in legacy mode (every
case exposed) and emits the existing deprecation advisory.
Adds Types\ExposedEnumCase and reshapes EnumType's internal constructor to take
the resolved exposed cases the mapper decided, replacing the parallel per-name
metadata arrays.
BREAKING CHANGE: partially-annotated #[Type] enums now hide their unannotated
cases from the schema. Annotate every case you want exposed.
* Emits a deprecation notice when a GraphQL-mapped enum declares zero {@see EnumValue}
190
-
* attributes across its cases — the signal that the developer has not yet engaged with
191
-
* the opt-in model that a future major release will require.
197
+
* attributes across its cases — the signal that the developer has not yet engaged with the
198
+
* per-case opt-in model.
199
+
*
200
+
* `#[EnumValue]` is now the per-case exposure toggle. As soon as an enum carries the attribute
201
+
* on at least one case it enters opt-in mode: only the annotated cases are exposed and every
202
+
* unannotated case is hidden from the schema (mirroring `#[Field]`'s opt-in model on classes).
203
+
* A fully-unannotated enum stays in legacy mode — every case is still exposed — and this notice
204
+
* fires to flag that the enum has not opted in, so a future major release that makes the
205
+
* attribute mandatory would otherwise hide all of its cases.
192
206
*
193
-
* Today every case is automatically exposed in the schema regardless of `#[EnumValue]` —
194
-
* this call site keeps that behaviour intact. The notice announces the planned migration:
195
-
* a future major release will require `#[EnumValue]` on each case that should participate
196
-
* in the schema, and unannotated cases will be hidden (mirroring `#[Field]`'s opt-in
197
-
* model on classes). Partial annotation is deliberately allowed and intentionally silent
198
-
* so that leaving some cases unannotated can be used to hide them once the default flips.
207
+
* Partial annotation is deliberately silent: leaving a case unannotated is now the supported
208
+
* mechanism for keeping it out of the public schema, so it must not itself produce an advisory.
199
209
*
200
210
* @param class-string<UnitEnum> $enumClass
201
211
*/
@@ -204,8 +214,8 @@ private function warnEnumHasNoEnumValueAttribute(string $enumClass): void
204
214
trigger_error(
205
215
sprintf(
206
216
'Enum "%s" is mapped to a GraphQL enum type but declares no #[EnumValue] attributes on any case. '
207
-
. 'Today every case is automatically exposed; a future major release will require #[EnumValue] on each case that should participate in the schema, and unannotated cases will be hidden (mirroring #[Field]\'s opt-in model on classes). '
208
-
. 'Add #[EnumValue] to every case you want to keep exposed. Omit it only from cases you want hidden from the public schema after the future default flip.',
217
+
. 'Every case is exposed in legacy mode; adding #[EnumValue] to any case switches the enum to opt-in mode, where only annotated cases are exposed and unannotated ones are hidden (mirroring #[Field]\'s opt-in model on classes). '
218
+
. 'Add #[EnumValue] to every case you want exposed. Omit it only from cases you want hidden from the public schema.',
0 commit comments