Skip to content

fix non nullable nested object marked as nullable #368

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

Merged
merged 4 commits into from
Sep 24, 2019
Merged

fix non nullable nested object marked as nullable #368

merged 4 commits into from
Sep 24, 2019

Conversation

de55
Copy link
Contributor

@de55 de55 commented Sep 22, 2019

📝 Description

Fix non nullable nested object marked as nullable and add/update tests.

🔗 Related Issues

This resolves #367

@codecov-io
Copy link

codecov-io commented Sep 22, 2019

Codecov Report

Merging #368 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #368      +/-   ##
============================================
- Coverage     94.46%   94.45%   -0.01%     
+ Complexity      323      322       -1     
============================================
  Files            97       96       -1     
  Lines          1139     1137       -2     
  Branches        204      204              
============================================
- Hits           1076     1074       -2     
  Misses           22       22              
  Partials         41       41
Impacted Files Coverage Δ Complexity Δ
.../com/expediagroup/graphql/generator/TypeBuilder.kt 96.96% <100%> (ø) 20 <0> (ø) ⬇️
.../graphql/generator/extensions/graphQLExtensions.kt 100% <100%> (ø) 0 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cb7ed1...c3f2d2b. Read the comment docs.

@@ -47,12 +47,12 @@ internal open class TypeBuilder constructor(protected val generator: SchemaGener

// Do not call the hook on GraphQLTypeReference as we have not generated the type yet
val unwrappedType = GraphQLTypeUtil.unwrapType(graphQLType).lastElement()
val typeWithNullability = graphQLType.wrapInNonNull(type)
Copy link
Contributor

Choose a reason for hiding this comment

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

This would throw an exception if I had a type returned from the hooks that correctly had it wrapped in a GraphQLNonNull right? I think we can refactor the wrapInNonNull method to have the logic to check if it is already non-null. If it is just return it instead of throwing an exception

@dariuszkuc What do you think?

Copy link
Contributor Author

@de55 de55 Sep 23, 2019

Choose a reason for hiding this comment

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

Not sure what the original purpose of throwing that error was, but it would have thrown an error if a GraphQLNonNull type contained anything besides a GraphQLTypeReference. I think the only ways for a GraphQLNonNull type to get into that method are to create a scalar type that is wrapped in GraphQLNonNull or implement onRewireGraphQLType to wrap a type in GraphQLNonNull. Idk if there is a valid use case for either one of those.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there is. Let's just change the logic and remove the exception and all its test cases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok done.

@smyrick smyrick added changes: patch Changes require a patch version type: bug Something isn't working labels Sep 24, 2019
@smyrick smyrick merged commit 4a70469 into ExpediaGroup:master Sep 24, 2019
@de55 de55 deleted the nested branch September 24, 2019 16:02
dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this pull request Aug 5, 2022
* fix non nullable nested object marked as nullable

* update federated schema nested test expected result

* fix lint issues

* return same type when GraphqlNonNull passed to wrapInNonNull
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: patch Changes require a patch version type: bug Something isn't working
Development

Successfully merging this pull request may close these issues.

Non Nullable Nested Objects marked as Nullable
3 participants