-
-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support subscriptions of value types #3876
Conversation
@@ -30,6 +30,20 @@ public async Task Basic() | |||
Observer.ShouldHaveNoMoreResults(); | |||
} | |||
|
|||
[Fact] | |||
public async Task BasicInt() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests the auto-registering types and worked without changes.
@@ -145,7 +153,7 @@ public MessageInputType() | |||
{ | |||
Field<StringGraphType>("fromId"); | |||
Field<StringGraphType>("content"); | |||
Field<DateGraphType>("sentAt"); | |||
Field<DateTimeOffsetGraphType>("sentAt"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the serialized responses would be repeatable as they would carry timezone info which can be set to UTC.
} | ||
|
||
[Fact] | ||
public async Task SubscribeInt() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests in this case direct usage of SourceStreamResolver, which is what all the field builders use.
{ | ||
Name = "messageCounter", | ||
Type = typeof(IntGraphType), | ||
StreamResolver = new SourceStreamResolver<int>(context => Subscribe(context).Select(_ => ++counter)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Threw exception here previously
if (typeof(TReturnType).IsValueType) | ||
throw new InvalidOperationException("The generic type TReturnType must not be a value type."); | ||
|
||
_sourceStreamResolver = context => new ValueTask<IObservable<object?>>((IObservable<object?>)sourceStreamResolver(context)); | ||
{ | ||
_sourceStreamResolver = context => new(new ObservableAdapter<TReturnType?>(sourceStreamResolver(context))); | ||
} | ||
else | ||
{ | ||
_sourceStreamResolver = context => new((IObservable<object?>)sourceStreamResolver(context)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this file are the only "real" changes in the project
if (typeof(TReturnType).IsValueType) | ||
{ | ||
_sourceStreamResolver = async context => new ObservableAdapter<TReturnType?>(await sourceStreamResolver(context.As<TSourceType>()).ConfigureAwait(false)); | ||
} | ||
else | ||
{ | ||
_sourceStreamResolver = async context => (IObservable<object?>)await sourceStreamResolver(context.As<TSourceType>()).ConfigureAwait(false); | ||
} |
Check notice
Code scanning / CodeQL
Missed ternary opportunity Note
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #3876 +/- ##
==========================================
- Coverage 84.66% 84.64% -0.02%
==========================================
Files 419 420 +1
Lines 19344 19360 +16
Branches 3037 3037
==========================================
+ Hits 16377 16388 +11
- Misses 2253 2259 +6
+ Partials 714 713 -1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who needs to sleep when you have an OSS to maintain?
That one was fast.
Yeah, well, my 1yo daughter has a fever and I needed to hold her anyway. I'll be really tired tomorrow. |
The hard part was updating all the tests...