navigation icon indicating copy to clipboard operation
navigation copied to clipboard

Graphql | Conflict between `site` and `language` parameters

Open Aku-benj opened this issue 8 months ago • 2 comments

Describe the bug

I have an issue where if I query a navigation via Graphql with a site and language parameters, the language param seems to make the site param useless.

Here are my sites : Image And in the multisite version : Image

Here is my test query :

query getNav {
	mainNavigation: navigationNodes(
	   site: "mainSiteFr"
       	   nav: "navMain"
      	   level: 1
      	   language: "en"
       ) {
		url
		title
		classes
		element {
			slug
		}
	}
}

And the result contains only the navigation Nodes of the mainSiteEn website. In that context, I expect and empty Result because the site mainSiteFr does not have the en language.

MultiSite version:

query getMainNav {
	mainNavigation: navigationNodes(site: "frSite1", nav: "navMain", level: 1, language: "fr") {
		url
		title
		classes
		element {
			slug
		}
	}
}

In a multisite context, this is even worse because the result comes from a different site in the same language.

Steps to reproduce (reproduce from screenshot above)

  1. Create 2 sites with different languages
  2. Create a navigation with some nodes on both sites
  3. Use the above gql query

Steps to reproduce Multisite (reproduce from screenshot above)

  1. Create 2 groups of 2 sites with same languages
  2. Create a navigation with some nodes on both sites
  3. Use the above gql query

Craft CMS version

5.6.11

Plugin version

3.0.6

Multi-site?

Both yes and no

Additional context

I have the headlessMode active in craft general.php, not sure if it matters

Aku-benj avatar Apr 03 '25 21:04 Aku-benj

Can I ask is there a reason to include both the site and the language? Seeing as though site's need to be unique, and navigation nodes are enabled based on a site, not a language, you use that?

engram-design avatar Apr 04 '25 11:04 engram-design

Hey, sorry for the delay. In my front context I have the siteHandles (that dont always contains the language) of all current site or subsite of the web query and in the gql query I send the multiple siteHandles like site: ["frSite1", "enSite1"] with the language parameter to get the proper navigation nodes.

Aku-benj avatar Apr 24 '25 15:04 Aku-benj