movio / bramble

A federated GraphQL API gateway
https://movio.github.io/bramble/
MIT License
497 stars 55 forks source link

Input types missing default values #254

Closed benzolium closed 4 months ago

benzolium commented 4 months ago

When I (or frontend lib) query merged schema:

{
  __type(name:"someName"){
    kind
    name
    inputFields {
      defaultValue
      name
    }
  }
}

I'm getting null as default values, tho I actually have some:

{
  "data": {
    "__type": {
      "kind": "INPUT_OBJECT",
      "name": "someName",
      "inputFields": [
        {
          "defaultValue": null,
          "name": "name"
        },
        {
          "defaultValue": null,
          "name": "description"
        },
      ]
    }
  }
}

I've reproduced it in a test: https://github.com/movio/bramble/commit/a7c3cbeaf10c3a166a9dad720704ee8ade63d433. I want to fix it, but I don't know, where to start. @pkqk, maybe you could guide me? I've already checked gqlparser - it looks fine. I have also written a test in merge_test.go and it's passing, but I have doubts because CheckSuccess helper is a bit complicated.

andyyu2004 commented 4 months ago

Hey @benzolium, relevant code is in resolveField and generally resolve* functions in executable_schema.go. Let me know if you need some further guidance on the implementation.

benzolium commented 4 months ago

Thanks @andyyu2004! I might be confused with "defaultValue" case in resolveInputValue so I've overlooked it. PR with a fix is ready.