-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
Make arguments required if they are non nullable #68
Make arguments required if they are non nullable #68
Conversation
After several iterations of implementation I decided to achieve this incorporating See the relevant discussion here - dart-lang/sdk#4188 (comment) This will add an analyser safety warnings and will not introduce breaking change as if it was through dart default |
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.
Although it doesn't seem so, this is a breking change (because of the need to import meta
(which makes sense btw), and the code used with generated !
variables would start make analyzer complain about new @required
annotation).
So could you bump it to 3.0.0 (on pubspec.yaml), and add an entry to changelog pointing the change to this PR + warning about meta
package?
lib/generator/print_helpers.dart
Outdated
|
||
// inserts import of meta package only if there is at least one non nullable input | ||
// see this link for details https://github.com/dart-lang/sdk/issues/4188#issuecomment-240322222 | ||
definition.queries.forEach((definition) { |
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.
I'm thinking about extracting this to a function, so you could just short-circuit the fn when a input.isNonNull
is found, return true so you could import the directive. Also, importMeta
var wouldn't be needed anymore.
While we decided to increment up to version
The output class for
I can improve my PR to support the next variant:
|
…-required' into feature/annotate-nonnullables-as-required
/// checks if the passed queries contain at least one non nullable field | ||
bool hasNonNullableInput(Iterable<QueryDefinition> queries) { | ||
for (var query in queries) { | ||
for (var input in query.inputs) { |
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.
you can also use Iterable.any, but it's the same thing
@vasilich6107 Yeah, I agree we should improve this as well as we're bumping a major. But let's add all parameters to constructors (both nullable and non-nullable), marking the non-nullable ones as |
Sure) |
I finished with some kind of initial implementation. Somewhere in tests I replaced one line queries with
From my perspective this type of notation could be easier to read and edit. Please review my code. Also I have a question about using a JSON representation for schema instead of simplified graphql notation. The JSON schema format also hardens the tests implementation. For example in issue #18 user gave us a schema and a sample query. After fixing the bug we could just create an additional test for this case. In case of JSON schema contributor should too much mental efforts on writing a test. May be we can discuss this topic via call? If it is ok fell free to choose the tool(skype, zoom, etc) |
@vasilich6107 I think this PR is good to go, or do you still want to change something?
Yeah, sure!
Are you talking about using Also, have a great Flutter Europe event! |
Yep, I'm talking about I'll get back to the issues after FlutterEurope. |
I'm gonna close this PR because I don't have write access to this branch. |
fixes #67
Hi) It's my first meaningful PR to this repo.
Please review if the overall flow is ok I'll add more test.