Skip to content

Remove deprecated .defaultValue() method #3285

Closed

Description

@georgeVlady0

Use of the deprecated GraphQL-Java method .defaultValue() rather than defaultValueProgrammatic() to specify default null value had resulted in schema linting issues and broken Apollo code generation tooling, but does not cause any immediate errors upon initial schema generation. Removing this deprecated method entirely would prevent this prevent users from having to create to manually check for usage of .defaultValue( null ) in their projects.

For example when creating a schema generated using SchemaPrinter, usage of .defaultValue( null ) with arguments and with input objects fields will result in the following:

TestQuery(
  testArg: Boolean = ,
)

input TestInput {
  testField: Boolean = 
}

Rather than:

TestQuery(
  testArg: Boolean = null,
)
input TestInput {
  testField: Boolean = null
}

In the JSON schema generated using IntrospectionQuery, this incorrectly manifests itself as shown below with defaultValue: "" . This breaks Apollo code generation tooling.

{
  "name" : "testField",
  "description" : null,
  "type" : {
    "kind" : "SCALAR",
    "name" : "Boolean",
    "ofType" : null
  },
  "defaultValue" : "",
  "isDeprecated" : false,
  "deprecationReason" : null
}

instead of defaultValue: "null"

{
  "name" : "testField",
  "description" : null,
  "type" : {
    "kind" : "SCALAR",
    "name" : "Boolean",
    "ofType" : null
  },
  "defaultValue" : "null",
  "isDeprecated" : false,
  "deprecationReason" : null
}

Activity

  1. bbakerman commented on Aug 8, 2023

    @bbakerman
    Member

    usage of .defaultValue( null ) with arguments and with input objects fields will result in the following:

    just to confirm - you are manually creating graphql.schema.GraphQLArgument and calling .defaultValue( null ) in that code?

    I want to ensure its not something that the SDL text -> schema is doing

  2. georgeVlady0 commented on Aug 8, 2023

    @georgeVlady0
    Author

    Hey, yes I can confirm that this issue results in manually creating graphql.schema.GraphQLArgument and calling .defaultValue( null )

  3. bbakerman commented on Aug 9, 2023

    @bbakerman
    Member

    I have made a reproduction test and can confirm this problem - we will look into this and see what's happening

  4. georgeVlady0 commented on Aug 9, 2023

    @georgeVlady0
    Author

    Thank you!

  5. dondonz commented on Aug 22, 2023

    @dondonz
    Member

    Merged in #3286

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions