WPGraphQL query returning wrong data I guess

According to my query, it should fetch the childItem under its parent page only but in my case, it is showing the child page as ChildItem as well as the main page also which is very confusing… Is it a bug in the plugin or I am doing it in the wrong way?

Image of my WP menu
https://ibb.co/TTCs2cz

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
              }
            }
          }
        }
      }
    }
  }
}

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."
      }
    ]
  }
}
  • This topic was modified 3 hours, 46 minutes ago by rustamveer.
  • This topic was modified 3 hours, 45 minutes ago by rustamveer.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Your Advertisement Here