-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[gatsby-source-drupal] relationship handling improvments #5020
Conversation
Deploy preview for gatsbygram ready! Built with commit a6ab3f2 |
Deploy preview for using-drupal ready! Built with commit a6ab3f2 |
Oh interesting — yeah, making the backref fields more explicit makes a lot of sense. What's the usecase for making those overridable in the plugin config? |
Sorry, I've missed that yesterday. So situation was that content node had field name taxonomyTermCategories {
relationships {
back_field_belongs_to_category {
# this is content node, but field name is a bit confusing
# allowing to name it like "linked_content_node" would make schema more self documented
# but we can't do that automatically because there would be issue described with
# "cross-sell" / "up-sell" scenario in PR description
title
}
} I'm not convinced that proposed solution is best (or even good) - not sure what's the nicest way to handle this |
I don't think I understand what this is doing 😅. Nudging @KyleAMathews for another look. |
I like this as it stands, tested it in my environment and it works. I am not sure about the second part, maybe make a todo for that so we can discuss? I am not sure I follow you, are you saying if both fields have the same machine name? Cause you can type different them, they would be added as multiple different types and you would just use
To get the specific one you want, so for paragraphs you can use
But maybe I don't follow what you are saying. 👍 |
This PR is working well and solving some problems I was encountering. FWIW. This merges cleanly with the V1 branch. Should it be re-rolled for Gatsby V2 (master branch)? And then back-ported for V1? |
@pieh you want to revisit this and get it landed in v1/master? |
Yeah, I'll update this so it can be merged to master before I open any new PR - but will have to handle #6261 first |
Let me know if there's anything I can do to help, and/or test things. |
… (arrays), fix back refs not showing for entities without any relationships, change backrefs to arrays as we can't ensure that backref will have single value Signed-off-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
Deploy preview for using-postcss-sass failed. Built with commit a6ab3f2 https://app.netlify.com/sites/using-postcss-sass/deploys/5b5086953813f00e269da002 |
Just gave this a test run using some Drupal Commerce data, and got the following error:
Which is at:
I did some basic debugging and I'm going to try and debug it some more and figure out which relationship is erroring. |
Hey, I'm working on it right now - I might have fix for it already locally. Let me push out my work here |
@mglaman can You pull and check again? |
Rad! I'll test after my commute and report back |
I'm still seeing one issue, but I honestly think it could be done in a follow up, so that multiple valued references can at least be fixed first. We have three taxonomy references on an entity. But only the first one is being provided as a relationship. When I fetch the product over JSON API I see the relationships available:
As I said, in my opinion the bigger blocker is not being able to receive all relationship values. |
That's great to hear! I was about to install docker to setup demo site that would actually test those changes (was doing test driven dev on this on today) :)
Do You have your site hosted somewhere (I seeYou use local url) so I could debug this issue? If so please let me know - either here or via mail if You don't want to show this publicly (misiek.piechowiak@gmail.com) |
@pieh :) here is a site! http://dev-commerce2x-jsonapi.pantheonsite.io/jsonapi Took a little to get set up (haven't used Pantheon in a long time) Here is the Gatsby setup I am using https://github.com/mglaman/gatsbyjs_commerce_demo |
Hm, weird. I think my local was just messed up. When I ran this query against that sandbox environment all was great!
|
@pieh thanks so much for helping unblock this :) |
This is ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave a glance over and it looks reasonable :-) So take that for what its worth haha :-D
I'll just merge it (it being opened for 3 months really bugs me) and if it cause problems it will be additional motivation to fix those :) |
Great work .. this is definitely something I'm going to need for a site I'm working on. Is a release planned for the near future? |
There is also one more breaking change I'd like to add here, but need to consult first:
Right now back references are added with names of referencing types - so if we would have hypothetical node type "Product" and 2 fields: "cross_sell" and "up_sell" than links to other products then both backrefs would all be dumped into single
node__product
field and we couldn't differentiate if current product is in cross-sell or up-sell relationship.Proposed solution:
Use name of relationship as base for back reference field name - maybe something like
back_${relationship_name}
and maybe allow setting that name in plugin settings: