verbb / navigation

A Craft CMS plugin to create navigation menus for your site.
Other
90 stars 23 forks source link

Option to override the Site URL #281

Closed market-south closed 2 years ago

market-south commented 2 years ago

What are you trying to do? GraphiQL query to return the node details with custom URL.

Currently, when we perform the GraphiQL query to return the node details of navigation (query as below). We are getting the response as expected without any issues.

Feature request: The URL field is returning the whole URL of the subdomain (request below) Craft is hosted in a subdomain whereas the official site is hosted in the primary domain running on Next Js and uses GraphiQL to get the contents. Though we have achieved the requirement using the nodeUri field It will be too handy and flexible if we have the option to override the Site Url for the URL field.

  mainNav: nodes(navHandle: "main") {
    ... on main_Node {
      id
      title
      nodeUri
      uri
      newWindow
      urlSuffix
           url
      type
      level
      parent: children {
        ... on main_Node {
          id
          title
          nodeUri
          uri
          newWindow
          urlSuffix
          type
          level
          child: children {
            ... on main_Node {
              id
              title
              nodeUri
              uri
              newWindow
              urlSuffix
              type
              level
            }
          }

        }
      }
    }
  }

What's your proposed solution?

To have an option to perform site URL override. SEomatic plugin is a good example of this feature.

Additional context Add any other context or screenshots about the feature request here.

GraphiQl response below

{
  "data": {
    "mainNav": [
      {
        "id": "2100",
        "title": "Our Story",
        "nodeUri": "our-story",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": null,
        "url": "https://admin.blueriverdairy.co.nz/our-story",
        "type": "craft\\elements\\Entry",
        "level": 1,
        "parent": [
          {
            "id": "2097",
            "title": "Who we are",
            "nodeUri": "our-story/who-we-are",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": null,
            "type": "craft\\elements\\Entry",
            "level": 2,
            "child": [
              {
                "id": "3644",
                "title": "Our Vision",
                "nodeUri": "our-story/who-we-are#our-vision",
                "uri": null,
                "newWindow": "0",
                "urlSuffix": "#our-vision",
                "type": "craft\\elements\\Entry",
                "level": 3
              },
              {
                "id": "2106",
                "title": "Our People",
                "nodeUri": "our-story/who-we-are#our__people",
                "uri": null,
                "newWindow": "0",
                "urlSuffix": "#our__people",
                "type": "craft\\elements\\Entry",
                "level": 3
              },
              {
                "id": "2107",
                "title": "Our History",
                "nodeUri": "our-story/who-we-are#our__history",
                "uri": null,
                "newWindow": "0",
                "urlSuffix": "#our__history",
                "type": "craft\\elements\\Entry",
                "level": 3
              },
              {
                "id": "2108",
                "title": "Awards",
                "nodeUri": "our-story/who-we-are#awards",
                "uri": null,
                "newWindow": "0",
                "urlSuffix": "#awards",
                "type": "craft\\elements\\Entry",
                "level": 3
              }
            ]
          },
          {
            "id": "2098",
            "title": "News",
            "nodeUri": "news",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": null,
            "type": "craft\\elements\\Entry",
            "level": 2,
            "child": []
          }
        ]
      },
      {
        "id": "2097",
        "title": "Who we are",
        "nodeUri": "our-story/who-we-are",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": null,
        "url": "https://admin.blueriverdairy.co.nz/our-story/who-we-are",
        "type": "craft\\elements\\Entry",
        "level": 2,
        "parent": [
          {
            "id": "3644",
            "title": "Our Vision",
            "nodeUri": "our-story/who-we-are#our-vision",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": "#our-vision",
            "type": "craft\\elements\\Entry",
            "level": 3,
            "child": []
          },
          {
            "id": "2106",
            "title": "Our People",
            "nodeUri": "our-story/who-we-are#our__people",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": "#our__people",
            "type": "craft\\elements\\Entry",
            "level": 3,
            "child": []
          },
          {
            "id": "2107",
            "title": "Our History",
            "nodeUri": "our-story/who-we-are#our__history",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": "#our__history",
            "type": "craft\\elements\\Entry",
            "level": 3,
            "child": []
          },
          {
            "id": "2108",
            "title": "Awards",
            "nodeUri": "our-story/who-we-are#awards",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": "#awards",
            "type": "craft\\elements\\Entry",
            "level": 3,
            "child": []
          }
        ]
      },
      {
        "id": "3644",
        "title": "Our Vision",
        "nodeUri": "our-story/who-we-are#our-vision",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": "#our-vision",
        "url": "https://admin.blueriverdairy.co.nz/our-story/who-we-are#our-vision",
        "type": "craft\\elements\\Entry",
        "level": 3,
        "parent": []
      },
      {
        "id": "2106",
        "title": "Our People",
        "nodeUri": "our-story/who-we-are#our__people",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": "#our__people",
        "url": "https://admin.blueriverdairy.co.nz/our-story/who-we-are#our__people",
        "type": "craft\\elements\\Entry",
        "level": 3,
        "parent": []
      },
      {
        "id": "2107",
        "title": "Our History",
        "nodeUri": "our-story/who-we-are#our__history",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": "#our__history",
        "url": "https://admin.blueriverdairy.co.nz/our-story/who-we-are#our__history",
        "type": "craft\\elements\\Entry",
        "level": 3,
        "parent": []
      },
      {
        "id": "2108",
        "title": "Awards",
        "nodeUri": "our-story/who-we-are#awards",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": "#awards",
        "url": "https://admin.blueriverdairy.co.nz/our-story/who-we-are#awards",
        "type": "craft\\elements\\Entry",
        "level": 3,
        "parent": []
      },
      {
        "id": "2098",
        "title": "News",
        "nodeUri": "news",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": null,
        "url": "https://admin.blueriverdairy.co.nz/news",
        "type": "craft\\elements\\Entry",
        "level": 2,
        "parent": []
      },
      {
        "id": "2110",
        "title": "Products and Services",
        "nodeUri": "products-and-services",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": null,
        "url": "https://admin.blueriverdairy.co.nz/products-and-services",
        "type": "craft\\elements\\Entry",
        "level": 1,
        "parent": [
          {
            "id": "2700",
            "title": "Infant formula & Toddler milk",
            "nodeUri": "products-and-services",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": "",
            "type": "craft\\elements\\Entry",
            "level": 2,
            "child": [
              {
                "id": "2699",
                "title": "New Zealand",
                "nodeUri": "products-and-services#products-nz",
                "uri": null,
                "newWindow": "0",
                "urlSuffix": "#products-nz",
                "type": "craft\\elements\\Entry",
                "level": 3
              },
              {
                "id": "2701",
                "title": "China",
                "nodeUri": "products-and-services#products-china",
                "uri": null,
                "newWindow": "0",
                "urlSuffix": "#products-china",
                "type": "craft\\elements\\Entry",
                "level": 3
              }
            ]
          },
          {
            "id": "2702",
            "title": "Services",
            "nodeUri": "products-and-services#services",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": "#services",
            "type": "craft\\elements\\Entry",
            "level": 2,
            "child": []
          }
        ]
      },
      {
        "id": "2700",
        "title": "Infant formula & Toddler milk",
        "nodeUri": "products-and-services",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": "",
        "url": "https://admin.blueriverdairy.co.nz/products-and-services",
        "type": "craft\\elements\\Entry",
        "level": 2,
        "parent": [
          {
            "id": "2699",
            "title": "New Zealand",
            "nodeUri": "products-and-services#products-nz",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": "#products-nz",
            "type": "craft\\elements\\Entry",
            "level": 3,
            "child": []
          },
          {
            "id": "2701",
            "title": "China",
            "nodeUri": "products-and-services#products-china",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": "#products-china",
            "type": "craft\\elements\\Entry",
            "level": 3,
            "child": []
          }
        ]
      },
      {
        "id": "2699",
        "title": "New Zealand",
        "nodeUri": "products-and-services#products-nz",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": "#products-nz",
        "url": "https://admin.blueriverdairy.co.nz/products-and-services#products-nz",
        "type": "craft\\elements\\Entry",
        "level": 3,
        "parent": []
      },
      {
        "id": "2701",
        "title": "China",
        "nodeUri": "products-and-services#products-china",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": "#products-china",
        "url": "https://admin.blueriverdairy.co.nz/products-and-services#products-china",
        "type": "craft\\elements\\Entry",
        "level": 3,
        "parent": []
      },
      {
        "id": "2702",
        "title": "Services",
        "nodeUri": "products-and-services#services",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": "#services",
        "url": "https://admin.blueriverdairy.co.nz/products-and-services#services",
        "type": "craft\\elements\\Entry",
        "level": 2,
        "parent": []
      },
      {
        "id": "2114",
        "title": "Shop",
        "nodeUri": "https://blueriverdairystore.co.nz/",
        "uri": null,
        "newWindow": "1",
        "urlSuffix": null,
        "url": "https://blueriverdairystore.co.nz/",
        "type": "",
        "level": 1,
        "parent": [
          {
            "id": "2711",
            "title": "Online store",
            "nodeUri": "https://blueriverdairystore.co.nz/",
            "uri": null,
            "newWindow": "1",
            "urlSuffix": null,
            "type": null,
            "level": 2,
            "child": []
          }
        ]
      },
      {
        "id": "2711",
        "title": "Online store",
        "nodeUri": "https://blueriverdairystore.co.nz/",
        "uri": null,
        "newWindow": "1",
        "urlSuffix": null,
        "url": "https://blueriverdairystore.co.nz/",
        "type": null,
        "level": 2,
        "parent": []
      },
      {
        "id": "2104",
        "title": "Careers",
        "nodeUri": "careers",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": null,
        "url": "https://admin.blueriverdairy.co.nz/careers",
        "type": "craft\\elements\\Entry",
        "level": 1,
        "parent": [
          {
            "id": "2103",
            "title": "From the team",
            "nodeUri": "careers#from_team",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": "#from_team",
            "type": "craft\\elements\\Entry",
            "level": 2,
            "child": []
          },
          {
            "id": "2105",
            "title": "Current Vacancies",
            "nodeUri": "careers#current-vacancies",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": "#current-vacancies",
            "type": "craft\\elements\\Entry",
            "level": 2,
            "child": []
          }
        ]
      },
      {
        "id": "2103",
        "title": "From the team",
        "nodeUri": "careers#from_team",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": "#from_team",
        "url": "https://admin.blueriverdairy.co.nz/careers#from_team",
        "type": "craft\\elements\\Entry",
        "level": 2,
        "parent": []
      },
      {
        "id": "2105",
        "title": "Current Vacancies",
        "nodeUri": "careers#current-vacancies",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": "#current-vacancies",
        "url": "https://admin.blueriverdairy.co.nz/careers#current-vacancies",
        "type": "craft\\elements\\Entry",
        "level": 2,
        "parent": []
      },
      {
        "id": "2109",
        "title": "Contact",
        "nodeUri": "contact",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": null,
        "url": "https://admin.blueriverdairy.co.nz/contact",
        "type": "craft\\elements\\Entry",
        "level": 1,
        "parent": [
          {
            "id": "2111",
            "title": "New Zealand",
            "nodeUri": "contact",
            "uri": null,
            "newWindow": "0",
            "urlSuffix": "",
            "type": "craft\\elements\\Entry",
            "level": 2,
            "child": []
          },
          {
            "id": "2113",
            "title": "China",
            "nodeUri": "http://www.blueriverdairy.com/",
            "uri": null,
            "newWindow": "1",
            "urlSuffix": null,
            "type": "",
            "level": 2,
            "child": []
          }
        ]
      },
      {
        "id": "2111",
        "title": "New Zealand",
        "nodeUri": "contact",
        "uri": null,
        "newWindow": "0",
        "urlSuffix": "",
        "url": "https://admin.blueriverdairy.co.nz/contact",
        "type": "craft\\elements\\Entry",
        "level": 2,
        "parent": []
      },
      {
        "id": "2113",
        "title": "China",
        "nodeUri": "http://www.blueriverdairy.com/",
        "uri": null,
        "newWindow": "1",
        "urlSuffix": null,
        "url": "http://www.blueriverdairy.com/",
        "type": "",
        "level": 2,
        "parent": []
      }
    ]
  }
}
engram-design commented 2 years ago

I was about to say, that's the reason for the nodeUri option, so that you can have a relative URL for this very purpose. I haven't looked at what SEOMatic is doing, but will look into it.

engram-design commented 2 years ago

My recommendation is to stick with nodeUri.