Closed xaviemirmon closed 5 years ago
Upon some further debugging, it seems that parent
is a value used elsewhere and is overriding the value provided by Drupal (perhaps in some GraphQL transformation). As far as I can work out there are two options:
We could copy the value of parent
to something like drupal_parent
so that it doesn't get overridden on whatever this transformation is. For example, in gatsby-source-drupal/gatsby-node.js
const node = nodeFromData(datum, createNodeId);
++ node.drupal_parent = node.parent; // Add Drupal parent
node.relationships = {}; // Add relationships
I've created a PR for that here
Alternatively, using the JSON:API Extras module in Drupal you can alter the id to drupal_parent
from parent
. However, this seems like an inferior solution as it would require all Drupal site add this module which they might not necessarily need.
parent
is something that Gatsby uses internally. drupal_parent
seems best way for it - and there is precedence for this (wordpress is setting wordpress_parent
for same reason.
@pieh Awesome thanks for letting me know.
Thanks so much for opening this issue!It seems like we’ve provided enough information to make an informed decision.
If this is not the case, or if we can help further--please don’t hesitate to reach out or comment on this issue, and we’d love to take another look.
Thanks for using Gatsby 💪
Hi @wardpeet the issue is resolved by the PR I've submitted. Shouldn't this remain open until that has been resolved? or do you folks do it differently? Thanks! Xavier
Oh, yeah, let's reopen the issue while PR is not merged yet - sorry for that.
Hey @pieh,
I've done a lot of digging around this issue and I think there are multiple things going on that are causing issues to querying menu link URLs with Gatsby and Drupal 8.
Drupal's JSON:API module provides a 1-to-1 relationship with the data as it is stored in the database. In most instances, this is to great benefit and is consistent when querying data. However, where it falls down is in the instance of links which are stored as [entity-type]:[UUID]
. This relationship causes a few issues when trying to link up with an alternative frontend such as Gatsby. What would be ideal is if the URL is the link's URL option or provides an option to get the URL.
I am working on turning the patch provided here into a full-blown Drupal module providing some field enhancers. This issue also indicates that there aren't intentions to change how the JSON:API is working either :disappointed:. Once I have done that, I'll see if I can turn it into a Gatsby specific settings module so that there could be a one click install that on top of your Drupal 8 site and it provides everything to Gatsby as expected. The downside to this approach is that I can see is it requires some extra Drupal modules but in the long term I think this will allow a lot more of the data to be provided in a usable way for Gatsby. Also, as this issue isn't one to do with Gatsby itself but how Drupal presents links, I don't think it should be down to Gatsby fix it and would require a lot of extra queries to get the correct data via the drupal-source-plugin.
The issue that does seem to be Gatsby related is that the parent label is reserved value and therefore applying my PR should fix that. For now, I think this should merge in and in a bit, when I have some free time, I'll look at how I can provide a more useful children element into the feed via the formerly mentioned module.
Also, once I build that out, I can look into seeing if there any manipulations that are required in the current gatsby-source-drupal plugin that could be avoided if the data provided by Drupal was a bit more useful.
How does that sound to you?
Thanks,
Xavier
Hiya!
This issue has gone quiet. Spooky quiet. 👻
We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 💪💜
Hey @pieh this issue isn't stale. Have you managed to think about the above?
Hey again!
It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY
. Please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks again for being part of the Gatsby community!
Fix published in gatsby-source-drupal@3.2.14
thanks to @xaviemirmon
@xaviemirmon i install last version of plugin drupal source with last version drupal 8 but i cannot found allMenuLinkContent... on graphql interface !! any idea to fixe this ??
@kamalkech Have you configured the right permissions on your drupal site? If you go to yoursite.com/jsonapi/menu/menu do you see the items there?
@xaviemirmon yes i can get list menu, but cannot get list links for example main menu need to get list links like : home, contact ....etc
What are you seeing on your Drupal JSON:API endpoint? Are those links there?
@xaviemirmon just list menus but withour links items
Ah yes! I think you'll need to do this @kamalkech
To expose the menu_link_content endpoint in the JSON:API you will need the Gatsby user to have the "Administer menus and menu items" permission. This can be done using basic_auth with the gatsby-source-drupal plugin or by using the key_auth module with Gatsby to an account with that permission.
Source: readme.txt
Description
I am seeing a value for the menu link content in the GraphiQL browser as null when I would expect it to be an ID
Steps to reproduce
Browse your menu in GraphiQL when you have a menu on Drupal with nested menu items
Expected result
According to the JSON:API there should be a string with the ID for nested menu links on the parent value.
Should be the string as follows in this instance: menu_link_content:8d61eedd-a561-4001-8df3-a439bd2acd65
Actual result
See image above it's returned null
Environment
System: OS: macOS 10.14.5 CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz Shell: 3.2.57 - /bin/bash Binaries: Node: 8.11.1 - /usr/local/bin/node Yarn: 1.7.0 - /usr/local/bin/yarn npm: 6.9.0 - ~/.npm-packages/bin/npm Languages: Python: 2.7.15 - /usr/local/bin/python Browsers: Chrome: 75.0.3770.100 Firefox: 66.0.5 Safari: 12.1.1 npmPackages: gatsby: ^2.8.5 => 2.8.5 gatsby-cli: ^2.6.5 => 2.6.5 gatsby-image: ^2.1.2 => 2.1.2 gatsby-plugin-manifest: ^2.1.1 => 2.1.1 gatsby-plugin-netlify-cache: ^1.2.0 => 1.2.0 gatsby-plugin-offline: ^2.1.1 => 2.1.1 gatsby-plugin-react-helmet: ^3.0.12 => 3.0.12 gatsby-plugin-sharp: ^2.1.3 => 2.1.3 gatsby-source-drupal: ^3.1.10 => 3.1.10 gatsby-source-filesystem: ^2.0.38 => 2.0.38 gatsby-transformer-sharp: ^2.1.21 => 2.1.21 npmGlobalPackages: gatsby-cli: 2.4.8