Skip to content

Specify nullness for some graphql.schema.idl classes #3895

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 3 commits into from
May 11, 2025

Conversation

mk868
Copy link
Contributor

@mk868 mk868 commented Apr 5, 2025

Related #3878

I applied @NullMarked on the classes:

  • graphql.Assert
  • graphql.schema.idl.FieldWiringEnvironment
  • graphql.schema.idl.InterfaceWiringEnvironment
  • graphql.schema.idl.ScalarInfo
  • graphql.schema.idl.ScalarWiringEnvironment
  • graphql.schema.idl.SchemaParser
  • graphql.schema.idl.TypeDefinitionRegistry
  • graphql.schema.idl.UnionWiringEnvironment
  • graphql.schema.idl.WiringEnvironment

Copy link
Member

@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

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

Lets decide on the Assert nullness question and then move forward

@bbakerman
Copy link
Member

I am geenrally happy with this PR so thank you. Its just that Assert is a special case and I am not sure how to move forward on that

@dondonz
Copy link
Member

dondonz commented Apr 12, 2025

Thanks for the pull request! I like your choice with Assert as well

Copy link
Member

@dondonz dondonz left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! We are on Easter break, will come back to your PR after the holidays

@dondonz
Copy link
Member

dondonz commented May 11, 2025

@bbakerman as discussed, the changes you suggested were implemented so merging in

@dondonz dondonz merged commit 7d9516a into graphql-java:master May 11, 2025
1 check passed
@bclozel
Copy link

bclozel commented May 13, 2025

I think method parameters in the Assert class should be annotated with @Nullable. We have a similar use case in Spring Framework with our own Assert class. As you can see there, we have annotated this method with a custom @Contract annotation that JSpecify can support if you declare that annotation in the build plugin.

Without that, null safety checks will fail because those method arguments are nullable by nature. The contract annotation lets JSpecify know that once it's checked, it cannot be null.

One last piece of feedback: adding @NullMarked at the class level might turn out to be a bit cumbersome in the long run. You can use that annotation at the package-info level in order to mark the entire package as @NullMarked. From my experience, this scales much better.

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.

4 participants