• Resolved Rustamveer Singh

    (@rustamveer)


    My WordPress Menu: https://ibb.co/TTCs2cz

    I am getting Child Page twice, once it is shown as a child page and another time it is displayed as a Level one Menu item, It must not show as a Level 1 menu page.

    Is it a bug in the plugin or I am doing it the wrong way????
    My WPGRAPHQL Query

    query mainMenu {
      menu(idType: NAME, id: "main menu") {
        menuItems {
          edges {
            node {
              id
              uri
              title
              target
              label
              childItems {
                edges {
                  node {
                    id
                    uri
                    title
                    target
                    label
                    parentId
                  }
                }
              }
            }
          }
        }
      }
    }

    WPGRAPHQL Query RESULT

    {
      "data": {
        "menu": {
          "menuItems": {
            "edges": [
              {
                "node": {
                  "id": "cG9zdDozNA==",
                  "uri": "/",
                  "title": "home link",
                  "target": null,
                  "label": "Home",
                  "childItems": {
                    "edges": []
                  }
                }
              },
              {
                "node": {
                  "id": "cG9zdDozMA==",
                  "uri": "/about-us/",
                  "title": null,
                  "target": null,
                  "label": "About Us",
                  "childItems": {
                    "edges": [
                      {
                        "node": {
                          "id": "cG9zdDo2MQ==",
                          "uri": "/child-page/",
                          "title": null,
                          "target": null,
                          "label": "Child page",
                          "parentId": "cG9zdDozMA=="
                        }
                      }
                    ]
                  }
                }
              },
              {
                "node": {
                  "id": "cG9zdDo2MQ==",
                  "uri": "/child-page/",
                  "title": null,
                  "target": null,
                  "label": "Child page",
                  "childItems": {
                    "edges": []
                  }
                }
              },
              {
                "node": {
                  "id": "cG9zdDoyOA==",
                  "uri": "/portfolio/",
                  "title": null,
                  "target": null,
                  "label": "Portfolio",
                  "childItems": {
                    "edges": []
                  }
                }
              },
              {
                "node": {
                  "id": "cG9zdDoyOQ==",
                  "uri": "/services/",
                  "title": null,
                  "target": null,
                  "label": "Services",
                  "childItems": {
                    "edges": []
                  }
                }
              },
              {
                "node": {
                  "id": "cG9zdDoyNw==",
                  "uri": "/contact-us/",
                  "title": null,
                  "target": null,
                  "label": "Contact Us",
                  "childItems": {
                    "edges": []
                  }
                }
              },
              {
                "node": {
                  "id": "cG9zdDozNw==",
                  "uri": "/policy/",
                  "title": null,
                  "target": null,
                  "label": "Policy",
                  "childItems": {
                    "edges": []
                  }
                }
              }
            ]
          }
        }
      },
      "extensions": {
        "debug": [
          {
            "type": "DEBUG_LOGS_INACTIVE",
            "message": "GraphQL Debug logging is not active. To see debug logs, GRAPHQL_DEBUG must be enabled."
          }
        ]
      }
    }

    Expected Result

    {
      "data": {
        "menu": {
          "menuItems": {
            "edges": [
              {
                "node": {
                  "id": "cG9zdDozNA==",
                  "uri": "/",
                  "title": "home link",
                  "target": null,
                  "label": "Home",
                  "childItems": {
                    "edges": []
                  }
                }
              },
              {
                "node": {
                  "id": "cG9zdDozMA==",
                  "uri": "/about-us/",
                  "title": null,
                  "target": null,
                  "label": "About Us",
                  "childItems": {
                    "edges": [
                      {
                        "node": {
                          "id": "cG9zdDo2MQ==",
                          "uri": "/child-page/",
                          "title": null,
                          "target": null,
                          "label": "Child page",
                          "parentId": "cG9zdDozMA=="
                        }
                      }
                    ]
                  }
                }
              },
              {
                "node": {
                  "id": "cG9zdDoyOA==",
                  "uri": "/portfolio/",
                  "title": null,
                  "target": null,
                  "label": "Portfolio",
                  "childItems": {
                    "edges": []
                  }
                }
              },
              {
                "node": {
                  "id": "cG9zdDoyOQ==",
                  "uri": "/services/",
                  "title": null,
                  "target": null,
                  "label": "Services",
                  "childItems": {
                    "edges": []
                  }
                }
              },
              {
                "node": {
                  "id": "cG9zdDoyNw==",
                  "uri": "/contact-us/",
                  "title": null,
                  "target": null,
                  "label": "Contact Us",
                  "childItems": {
                    "edges": []
                  }
                }
              },
              {
                "node": {
                  "id": "cG9zdDozNw==",
                  "uri": "/policy/",
                  "title": null,
                  "target": null,
                  "label": "Policy",
                  "childItems": {
                    "edges": []
                  }
                }
              }
            ]
          }
        }
      },
      "extensions": {
        "debug": [
          {
            "type": "DEBUG_LOGS_INACTIVE",
            "message": "GraphQL Debug logging is not active. To see debug logs, GRAPHQL_DEBUG must be enabled."
          }
        ]
      }
    }
Viewing 1 replies (of 1 total)
  • Thread Starter Rustamveer Singh

    (@rustamveer)

    Reply by David Levine
    You can set parentDatabaseId to 0 to return only top level items, and get the submenus as child items.

Viewing 1 replies (of 1 total)
  • The topic ‘Getting Wrong Data via WPGRAPHQL Query’ is closed to new replies.