Apollo кеш данных с динамическими свойствами. Как сделать запрос? - PullRequest
0 голосов
/ 08 октября 2019

У меня есть такой объект, который хранится в моем кэше Apollo.

{
  "__typename": "nav",
  "dashboard": {
    "link": {
      "strings": {
        "text": "Mi Gestor",
        "title": "..."
      },
      "to": "#0",
      "icon": "u-icon-informanager"
    }
  },
  "elements": [
    {
      "strings": {
        "text": "informa.es"
      },
      "link": {
        "strings": {
          "text": "Mi Gestor",
          "title": "..."
        },
        "to": "#0",
        "icon": "u-icon-informanager"
      },
      "list": {
        "elements": [
          {
            "strings": {
              "text": "Registro de Tráfico - DGT"
            }
          },
          {
            "link": {
              "strings": {
                "text": "Informe de Vehículo",
                "title": "Informe de Vehículo"
              },
              "to": "https://www.google.es"
            }
          }
        ]
      }
    },
    {
      "link": {
        "icon": "u-icon-arrow-down",
        "strings": {
          "text": "Informes",
          "title": "Informes"
        },
        "to": "https://www.google.es"
      },
      "list": {
        "elements": [
          {
            "strings": {
              "text": "Informes"
            },
          },
          {
            "link": {
              "icon": "",
              "strings": {
                "text": "Informaes Nacionales",
                "title": "Informaes Nacionales"
              },
              "to": "https://www.google.es"
            },
          },
          {
            "link": {
              "icon": "",
              "strings": {
                "text": "Informaes Internacionales",
                "title": "Informaes Internacionales"
              },
              "to": "https://www.google.es"
            },
          },
          {
            "link": {
              "icon": "",
              "strings": {
                "text": "Informes Investigados",
                "title": "Informes Investigados"
              },
              "to": "https://www.google.es"
            },
          },
          {
            "link": {
              "icon": "",
              "strings": {
                "text": "Informes Prejudiciales",
                "title": "Informes Prejudiciales"
              },
              "to": "https://www.google.es"
            },
          },
        {
          "link": {
            "icon": "",
            "strings": {
              "text": "Informes Solicitados",
              "title": "Informes Solicitados"
            },
            "to": "https://www.google.es"
          },
        }
    ]
  }
}
]
}

Извините за идентификацию. Я пытался отформатировать его правильно, но я не могу справиться с этим очень хорошо.

Здесь запрос, который я пытаюсь использовать:

query GetNav {
    user @client {
      __typename
      nav {
        dashboard {
          link {
            to
            strings {
              text
              title
            }
            icon
          }
        }
        elements {
          strings {
            text
          }
          link {
            to
            strings {
              text
              title
            }
            icon
          }
          list {
            elements {
              strings {
                text
              }
              link {
                to
                strings {
                  text
                  title
                }
                icon
              }
            }
          }
        }
      }
    }
  }

Однако, что яполучение - это только пустые объекты в последнем списке:

enter image description here

У вас есть идеи, что может произойти? Я знаю, что GraphQL ориентирован на схемы и что они должны быть точными, но я также подумал, что несуществующие свойства этих схем не нарушат данные результата.

...