Conversation
🦋 Changeset detectedLatest commit: 91bda67 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thank you for the PR, having been a bit involved with the semanticNullability proposals and implementing them, I don't think we should merge or pursue this until there is clarity. Notice that the proposal is set at RFC0 and there are a lot of competing proposals. |
|
Closing, sorry. There's no clear or single spec proposal here, and no clarity on a path forward or reference implementation that's up to date. For context, for example when we implemented The semantic nullability proposals have gone through this but worse. It's confusing. There's no specification to follow. And there's no unified reference implementation or specification. So, closing, since I don't think it even makes sense to keep a PR going that's basically "out of spec" (since there isn't a spec for a proposal, i.e. the proposal has been modified and knocked back so many times, it's basically even pre-Stage-0) |
|
Okay. I thought that it being supported for example in projects such as It would be nice to have this addition. Since it is opt-in I don't really see the drawback? |
Summary
This adds support for the
@semanticNonNulldirective, which is part of the semantic nullability proposal being explored by the GraphQL Working Group.The directive indicates that a field is semantically non-null - it will only be null in error scenarios. When applied to a field,
@semanticNonNullcauses gql.tada to infer a non-nullable TypeScript type, similar to@required.Example
Before (without @semanticNonNull):
{ todos: Array<{ complete: boolean | null; author: { id: string; name: string; } | null; } | null> | null; }After (with @semanticNonNull):
{ todos: Array<{ complete: boolean; // no longer nullable author: { // no longer nullable id: string; name: string; }; } | null> | null; }Set of changes
Modified getTypeDirective in src/selection.ts to recognize @semanticNonNull alongside @required and @_required
Added test case in src/tests/selection.test-d.ts
This is a non-breaking, additive change.