Skip to content
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

Added support for null input arguments (Improved) #374

Closed
wants to merge 1 commit into from

Conversation

AndyBan
Copy link
Contributor

@AndyBan AndyBan commented Jul 17, 2017

Replaces #306

The other pull looks to be dead and has issues which I have resolved.

Requires graphql-dotnet/parser#17

Build will fail until the other PR is merged, let me know if you need anything else from me.

@joemcbride
Copy link
Member

joemcbride commented Jul 17, 2017

Thanks for the PR! You can fix the build by temporarily adding the myget.org nuget source to use your changes and make sure all the tests pass.

https://www.myget.org/feed/graphql-dotnet/package/nuget/GraphQL-Parser

https://www.myget.org/F/graphql-dotnet/api/v3/index.json

https://github.com/graphql-dotnet/graphql-dotnet/blob/master/src/NuGet.config

@AndyBan
Copy link
Contributor Author

AndyBan commented Jul 17, 2017

I think your CI is broken? The myget feed hasn't updated in a few days. Appveyor has the package but the feed asks me for a password so I guess that isn't public. If I download it and use it in a local feed then all the tests pass.

https://i.imgur.com/VfPygy4.png

@joemcbride
Copy link
Member

Ah, yeah - its not broken, but the myget deploy is restricted by branch which I forgot about. You could perhaps add your branch to the appveyor.yml, but if you did it manually then I'm not worried about it. Will have this CI re-run once a new package is officially released.

public class NullValue : AbstractNode, IValue
{

public string Value { get; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need this Value property at all?

@joemcbride
Copy link
Member

Some other places we probably want to update:

  • AstFromValue extension method.
  • AstPrinter
  • SchemaPrinter - may need to look at the graphql-js project and see what they do with NullValue. Perhaps only need to worry about it with DefaultValue argument values?

@AndyBan
Copy link
Contributor Author

AndyBan commented Jul 18, 2017

I have resolved the first two comments. I don't think the schema printer needs to know about the NullValue AST object as it can never end up with one. The printer will only deal with actual types or types wrapped in non null never actual values (Ignoring the default which might be null but that's the value not the AST type).

The JS project just passes null around being untyped which I did consider doing here but it does make the code a bit more messier in C# land as you end up changing int to int? etc and then having to check everywhere where you use that value that you have a value.


Config<NullValue>(c =>
{
c.Print(f => null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should print the text null vs. just a null value.

c.Print(f => "null");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? If you do that you end up with null in a string which correctly fails a couple of unit tests:

Message: Assert.Equal() Failure
↓ (pos 29307)
Expected: ··· "defaultValue": null\r\n }\r\n ]\r\n },\r\n ···
Actual: ··· "defaultValue": "null"\r\n }\r\n ]\r\n },\r···
↑ (pos 29307)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch pushed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you need it squashing once your happy

@joemcbride
Copy link
Member

It looks like the JS project uses astFromValue to convert the DefaultValue. That looks like an existing bug in our SchemaPrinter. No need to fix that now if you don't want.

@AndyBan
Copy link
Contributor Author

AndyBan commented Jul 19, 2017

A bit pushed for time at the moment so I'll hold off on that one.

I tried changing the parser ci branch config but after looking into it they have disabled deployment for pull requests for non trusted people.

@AndyBan
Copy link
Contributor Author

AndyBan commented Aug 8, 2017

I have renamed null -> Nullvalue as reviewed on the parser repo and squashed all the commits. Let me know if there is anything blocking this from being merged.

@AndyBan
Copy link
Contributor Author

AndyBan commented Aug 9, 2017

I have pointed to the custom MyGet feed now the Parser change has been merged. Let me know if you want that commit removing but I think it might be best left in?

Edit: I have removed the CI change in response to the below. Here was the green build: https://ci.appveyor.com/project/graphql-dotnet-ci/graphql-dotnet/build/0.17.2.756-jtrsgfnc

@joemcbride
Copy link
Member

It will need to be removed once an official release of v3 of the parser is on Nuget.org. I want to make a few tweaks to the parser project before officially releasing it. I'll do that today.

@tlil
Copy link
Contributor

tlil commented Aug 16, 2017

I want to make a few tweaks to the parser project before officially releasing it. I'll do that today.

@joemcbride did you make any progress on that?

@joemcbride
Copy link
Member

@tlil yes, see th dev branch in that project.

@enkodellc
Copy link

What is the status of this? Wouldn't this reduce the need for multiple GraphQL queries for arguments. Can the feature be applied to Variables as well? Thanks for all the work on the project. I hope to learn a bit more and contribute.

@AndyBan
Copy link
Contributor Author

AndyBan commented Aug 31, 2017

Its been ready for merging for 6 weeks now afaik - I think @joemcbride is waiting for some other unrelated features to do a major version bump. I don't think this feature requires a major version bump itself.

Variables look to be working correctly with my PR.

@joemcbride
Copy link
Member

The issue is the building of the Parser nuget package. That build process had to be changed and I haven't been able to 100% verify its working yet. Since this is a behavior change in the parser, yes it requires a major version bump. Ditto for this project.

graphql-dotnet/parser#18

@joemcbride joemcbride mentioned this pull request Sep 8, 2017
@joemcbride
Copy link
Member

Got the parser project updated and added #421 which merges these changes.

@joemcbride joemcbride closed this Sep 8, 2017
Copy link
Contributor

@holm0563 holm0563 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed introspection tests now fail in graph iql. Seems like these should be reverted.

@@ -369,7 +369,7 @@ public void allows_querying_field_args()
'kind': 'SCALAR'
}
},
'defaultValue': null
'defaultValue': 'null'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is making GraphIQL not able to parse the introspection. Is anyone else having this problem?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note after reverting this change set, graph iql works as expected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joemcbride should this be sent as a new issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@holm0563 may need to bump the GraphiQL version to one that supports the null keyword perhaps?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joemcbride i didn't look at the spec but I'd be shocked if its truly supposed to change to 'null' as a string?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AH, I see what you're saying.

https://github.com/graphql/graphql-js/blob/4f5e351c2afb28e4ae3a44eae76d45d895ff3aa2/src/utilities/astFromValue.js#L70-L78

The JS project treats null different than undefined and NaN. We don't have the "luxury" of 3 different "nulls" in C#. Will have to decide on the best course of action here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants