Skip to content

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

Merged
dondonz merged 3 commits into
graphql-java:masterfrom
mk868:jspecify-idl
May 11, 2025
Merged

Specify nullness for some graphql.schema.idl classes#3895
dondonz merged 3 commits into
graphql-java:masterfrom
mk868:jspecify-idl

Conversation

@mk868

@mk868 mk868 commented Apr 5, 2025

Copy link
Copy Markdown
Contributor

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

@bbakerman bbakerman left a comment

Copy link
Copy Markdown
Member

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

Comment thread src/main/java/graphql/Assert.java Outdated
@bbakerman

Copy link
Copy Markdown
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

Comment thread src/main/java/graphql/schema/idl/TypeDefinitionRegistry.java
@dondonz

dondonz commented Apr 12, 2025

Copy link
Copy Markdown
Member

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

@dondonz dondonz left a comment

Copy link
Copy Markdown
Member

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

dondonz commented May 11, 2025

Copy link
Copy Markdown
Member

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

@dondonz dondonz merged commit 7d9516a into graphql-java:master May 11, 2025
@bclozel

bclozel commented May 13, 2025

Copy link
Copy Markdown

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