Skip to content

Commit bb2a396

Browse files
committed
docs: trim the enum migration subsection — short-lived transitional content
1 parent 077a484 commit bb2a396

1 file changed

Lines changed: 8 additions & 40 deletions

File tree

website/docs/descriptions.md

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -129,48 +129,16 @@ is an enum value.
129129
Omitting it falls back to the `@deprecated` tag on the case docblock. An explicit empty string
130130
`''` deliberately clears any inherited `@deprecated` tag.
131131

132-
### Future migration: `#[EnumValue]` will become required per `#[Type]`-mapped enum
133-
134-
Today every case of a `#[Type]`-mapped enum is automatically exposed in the GraphQL schema. A
135-
future major release will flip this to an opt-in model: **`#[Type]`-mapped enums will need at
136-
least one `#[EnumValue]`-annotated case, and only annotated cases will participate in the
137-
schema**, mirroring the way `#[Field]` opts individual methods and properties into an object
138-
type.
139-
140-
The benefit is selective exposure — today there is no way to map a subset of a PHP enum into
141-
GraphQL, which forces schema authors to split an enum into two or rename cases. Under the
142-
opt-in model, an internal enum case can simply omit `#[EnumValue]` to stay out of the public
143-
schema. **Partial annotation is intentional and deliberately silent**: leaving some cases
144-
unannotated is the mechanism for hiding them from the public schema once the default flips,
145-
not a migration oversight.
146-
147-
To surface the upcoming change, GraphQLite emits a PHP `E_USER_DEPRECATED` notice at schema
148-
build time only when a `#[Type]`-mapped enum declares **zero** `#[EnumValue]` attributes
149-
across its cases — the signal that the developer has not yet engaged with the opt-in model at
150-
all. Annotating at least one case acknowledges the new model and silences the notice; after
151-
that, any combination of annotated and unannotated cases is correct and intentional.
152-
153-
Adopters who aren't ready to decide which cases to expose can silence the advisory with a
154-
bare `#[EnumValue]` on a single case — no description, no deprecation, just the acknowledgement:
132+
### Future migration
155133

156-
```php
157-
#[Type]
158-
enum Size
159-
{
160-
#[EnumValue] // acknowledges the opt-in migration; runtime behaviour unchanged
161-
case S;
162-
case M;
163-
case L;
164-
}
165-
```
134+
A future major release will require at least one `#[EnumValue]`-annotated case per
135+
`#[Type]`-mapped enum; only annotated cases will be exposed in the schema (mirroring
136+
`#[Field]`'s opt-in model). Today every case is still auto-exposed, so nothing breaks.
166137

167-
**Runtime implication after the flip.** Cases without `#[EnumValue]` will not exist in the
168-
GraphQL schema, so a resolver that returns such a case will trigger webonyx/graphql-php's
169-
standard enum serialization error (the value is not listed in the enum type's `values`
170-
config). This is the same spec-compliant behaviour that applies to any unknown enum value and
171-
is the mechanism that makes selective exposure safe: internal cases cannot accidentally leak
172-
via a resolver. Developers who want a case to remain returnable must keep `#[EnumValue]` on
173-
it; omitting the attribute is a deliberate "do not expose this value" signal.
138+
GraphQLite emits a deprecation notice only when a `#[Type]`-mapped enum has **zero**
139+
`#[EnumValue]` attributes — annotating any single case silences it and acknowledges the
140+
model. Partial annotation is intentional: an unannotated case is how you hide a value from
141+
the public schema once the default flips.
174142

175143
## Description uniqueness on `#[ExtendType]`
176144

0 commit comments

Comments
 (0)