americanas-tech/restQL-golang

List as a field on key-value structure always mutiplex

rodrigodc07 opened this issue · 1 comments

On the key-value structure, if one of the fields of the structure is a list restQL automatically multiplex it, but we can't use no-multiplex function inside a key-value structure.

Exemple: Send the following body as a POST

{
  "hero": {
    "id": "123",
    "sidekicks": [
      "1",
      "2"
    ]
  }
}

Proposal:

to installment
	with
  	hero = {
              id : "123",
              sidekicks : ["1","2"] -> no-multiplex
        }

Actually this is not really a bug but rather an expected but unsual result of two restQL features:

  • Object explosion: by default, restQL turn a object with a list field into a list of objects, each with a value of the list as the fields value. For example, the following body
 {
      "id" : "123",
      "sidekicks" : ["1","2"]
}

Will became:

[
  {
        "id" : "123",
        "sidekicks" : "1"
  },
  {
        "id" : "123",
        "sidekicks" : "2"
  }
]
  • Multiplexing: by default, an statement with a list parameter will perform n HTTP request, where n is the size of the list.

It is intentional that a user explode its object parameter and send it as a unique list to the API by disabling the multiplexing feature with the no-multiplex function.

However, today restQL do not support the case where a user don't want to explode his object parameter. I will introduce a pull request adding a no-explode function that should address this.