DivvyPayHQ/absinthe_federation

Support nested selection sets

kdawgwilk opened this issue · 3 comments

We need to make sure we support nested selection sets e.g. "id organization { id }"

_FieldSet docs https://www.apollographql.com/docs/federation/federation-spec/#scalar-_fieldset

Did a test of this and the string -> atom conversion on _FieldSet only happens at one layer unfortunately right now so there is some work to be done here e.g.

variables=%{"representations" => [%{"__typename" => "Product", "sku" => "federation", "variation" => %{"id" => "OSS"}}]}

query ($representations: [_Any!]!) {
  _entities(representations: $representations) {
    ...on Product { id }
  }
}
{
  "representations": [
    {
      "__typename": "Product",
      "sku": "federation",
      "variation": {
        "id": "OSS"
      }
    }
]}

Came through in the :_resolve_reference resolver as:

  defp resolve_product_reference(%{sku: sku, variation: %{"id" => variation_id}}, _ctx) do

notice the id is a string not an atom

The code to improve this support is likely

args = for {key, val} <- representation, into: %{}, do: {String.to_atom(key), val}
and
args = for {key, val} <- representation, into: %{}, do: {String.to_atom(key), val}

Where it only converts the top-level keys and not nested keys

Closed by #34