micronaut-projects / micronaut-graphql

A repository for Micronaut and GraphQL integrations
Apache License 2.0
84 stars 44 forks source link

Fails to parse valid Apollo subscription messages which contain extensions field #75

Open sekoyo opened 4 years ago

sekoyo commented 4 years ago

Describe the bug

Apollo sends an extensions: {} field with subscription queries like so:

{
  "id": "1",
  "type": "start",
  "payload": {
    "variables": {
      "_v0_symbol": "btcusd"
    },
    "extensions": {},
    "operationName": null,
    "query": "subscription ($_v0_symbol: String) {  ticker(symbol: $_v0_symbol) {    average    createdAtTimestamp  }}"
  }
}

Unless extensions is removed or changed to undefined then the java graphql server refuses to parse the valid message. In Micronaut v1 it threw a JSON parse exeption, in Micronaut v2 it doesn't throw but a response is not sent unless extensions is undefined or not present.

To Reproduce

Send a query with extensions: {} for example:

{
  "id": "1",
  "type": "start",
  "payload": {
    "variables": {
      "marketId": "BTCUSD"
    },
    "extensions": {},
    "operationName": "TickerForTradeSubscription",
    "query": "subscription TickerForTradeSubscription($marketId: String!) {\n  ticker(symbol: $marketId) {\n    symbol\n    open\n    low\n    high\n    baseVolume\n    bestBid\n    bestAsk\n    last\n    lastTradeSize\n    createdAtTimestamp\n    __typename\n  }\n}\n"
  }
}

Environment Information

ilopmar commented 4 years ago

Can you please share an app that reproduces the issue?

gklijs commented 3 years ago

Seems like they should/could be added to https://github.com/micronaut-projects/micronaut-graphql/blob/master/graphql/src/main/java/io/micronaut/configuration/graphql/GraphQLRequestBody.java but it's a bit lame to just make it a valid object, and further ignore extensions.