micronaut-graphql icon indicating copy to clipboard operation
micronaut-graphql copied to clipboard

Micronaut GraphQL as native-image does not work properly

Open eratolekov opened this issue 2 years ago • 1 comments

Expected Behavior

The graphlql response:

{
  "data": {
    "products": [
      {
        "id": "1",
        "extId": "Ext34",
        "kind": "Kind2"
      }
    ]
  }
}

Actual Behaviour

The graphlql response:

{
  "errors": [
    {
      "message": "The field at path '/products[0]/id' was declared as a non null type, but the code involved in retrieving data has wrongly returned a null value.  The graphql specification requires that the parent field be set to null, or if that is non nullable that it bubble up null to its parent and so on. The non-nullable type is 'ID' within parent type 'Product'",
      "path": [
        "products",
        0,
        "id"
      ],
      "extensions": {
        "classification": "NullValueInNonNullableField"
      }
    },
    {
      "message": "The field at path '/products[0]/extId' was declared as a non null type, but the code involved in retrieving data has wrongly returned a null value.  The graphql specification requires that the parent field be set to null, or if that is non nullable that it bubble up null to its parent and so on. The non-nullable type is 'String' within parent type 'Product'",
      "path": [
        "products",
        0,
        "extId"
      ],
      "extensions": {
        "classification": "NullValueInNonNullableField"
      }
    },
    {
      "message": "The field at path '/products[0]/kind' was declared as a non null type, but the code involved in retrieving data has wrongly returned a null value.  The graphql specification requires that the parent field be set to null, or if that is non nullable that it bubble up null to its parent and so on. The non-nullable type is 'String' within parent type 'Product'",
      "path": [
        "products",
        0,
        "kind"
      ],
      "extensions": {
        "classification": "NullValueInNonNullableField"
      }
    }
  ],
  "data": {
    "products": [
      null
    ]
  }
}

Steps To Reproduce

Build the micronaut native-image application:

./gradlew nativeCompile

Run the micronaut native-image application:

./build/native/nativeCompile/graphql-native-bug

Open the url http://localhost:8080/graphiql

Execute the graphql query:

{
  products {
    id
    extId
    kind
  }
}

See the graphql response.

Though the micronaut openjdk application works properly. The actual result of the micronaut openjdk application is presented at Expected Behaviour section above.

Environment Information

  • OS Ubuntu 20.04
  • graalvm-ce-java17-22.1.0

Example Application

https://github.com/eratolekov/micronaut-graphql-native-bug

Version

3.6.2

eratolekov avatar Sep 06 '22 17:09 eratolekov

Curious to know if there is any update on this issue? I am experiencing it as well.

rmberg avatar Feb 03 '23 14:02 rmberg