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

feat: Add null support #6

Merged
merged 1 commit into from
Sep 13, 2022
Merged

Conversation

AndrewSisley
Copy link

@AndrewSisley AndrewSisley commented Sep 12, 2022

Partially resolves sourcenetwork/defradb#410

Code is mostly copy-pasted from the PR graphql-go#536 by https://github.com/mpenick - main difference is that I haven't copied over a couple of new tests, and that I permitted null within arrays (unanswered question in original PR, and I see no reason for it too). I have changed that code as little as possible otherwise. Builds and tests pass.

Follows the GQL spec as far as I can see (Nulls got added here: graphql/graphql-spec#83)

I have incorporated this feature into a Defra branch and it seems to be working https://github.com/sourcenetwork/defradb/compare/sisley/feat/I410-filter-by-nil?expand=1 (got more tests to write though, will finish those before merging this)

  • Finish defra tests before merge

Code is mostly copy-pasted from the PR graphql-go#536 - main difference is that I haven't copied over a couple of new tests, and that I permitted null within arrays (unanswered question in original PR, and I see no reason for it too).
@@ -1188,7 +1188,7 @@ func TestVariables_ListsAndNullability_DoesNotAllowListOfNonNullsToContainNull(t
{
Message: `Variable "$input" got invalid value ` +
`["A",null,"B"].` +
"\nIn element #1: Expected \"String!\", found null.",
"\nIn element #2: Expected \"String!\", found null.",
Copy link
Member

Choose a reason for hiding this comment

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

question: do you know why was this saying element #1 was null before?

Copy link
Author

Choose a reason for hiding this comment

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

no idea

Copy link

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

Looking good overall. Just a few things to take a look at bellow 🙂

values.go Show resolved Hide resolved
values.go Show resolved Hide resolved
Comment on lines +44 to +48
if tmp == nil {
return nullValue{} // Null value
} else {
return tmp
}

Choose a reason for hiding this comment

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

suggestion: No else needed here since if ends with a return.

Copy link
Author

Choose a reason for hiding this comment

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

Seems to be the norm in this repo, will leave as is unless we decide to take full ownership of the project

Choose a reason for hiding this comment

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

If it's copy pasted code I'll agree but if it's our code I would change it to the idiomatic form.

@AndrewSisley AndrewSisley merged commit ead59e5 into develop Sep 13, 2022
@AndrewSisley AndrewSisley deleted the sisley/feat/I410-filter-by-nil branch September 13, 2022 19:13
fredcarle pushed a commit that referenced this pull request Apr 25, 2023
Code is mostly copy-pasted from the PR graphql-go#536 - main difference is that I haven't copied over a couple of new tests, and that I permitted null within arrays (unanswered question in original PR, and I see no reason for it too).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants