-
Notifications
You must be signed in to change notification settings - Fork 21
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
Implement defaultValue for @Arg #53
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #53 +/- ##
=======================================
Coverage 87.44% 87.44%
=======================================
Files 61 61
Lines 1107 1107
Branches 194 194
=======================================
Hits 968 968
Misses 138 138
Partials 1 1
Continue to review full report at Codecov.
|
@@ -91,25 +91,60 @@ describe('Arguments with @Arg', () => { | |||
}); | |||
|
|||
it('Will allow registering argument at runtime', () => { | |||
@ObjectType() |
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 test should keep focusing only on registering args at runtime. Having default values tested here pollutes this test
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.
yeah I agree, I haven't actually changed this test at all, I have no idea why github has decided to render the diff like this, my own tools don't. Though it does look like something autoformatted the parameter block (line 97), maybe that's it.
src/test/arg/basics.spec.ts
Outdated
return baz; | ||
} | ||
} | ||
const compiledObject = compileObjectType(Foo); |
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.
Would be good to test it basing on resolving some field that is based on knowing default value.
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.
Yeah I couldn't think of a way to do this, maybe defining a schema in the test, compiling it and executing against it?
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.
Added such a condition, I hope async/await is OK, seemed the easiest way to do it.
Reverted format change to pre-existing test
Found reference to having defaultValue defined in the docs, but it isn't actually in the code (and I thought it'd be good to use).
I figured it should be fairly straightforward to implement, so I've had a go. The only thing I'm not clear about is whether having a defaultValue defined means the type is nullable? I think they are independent still, so I've left isNullable alone.
Hopefully I haven't missed anything, I haven't made an effort to try and understand the whole codebase, just the bits I was interested in.