-
Notifications
You must be signed in to change notification settings - Fork 639
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
"Full data" GraphQL mode for Link fields #16237
Conversation
@brandonkelly looking forward to this getting released so that I can use the native link field in my new project instead of a plugin. One thing I'd like to surface is that it would be best to be able to get the relative path for internal links, basically anything of the Entry type. I'm using NextJs, and in order for the links to function properly I need to use a relative path for internal links.
Is it possible to return the I've been using Typed Link Field for a few years and the query looks like this:
Then the Link component in React can switch handle output differently based on type
|
Haven't tried Hyper, but they have a |
I don’t see that being necessary. You can extract the URI from the |
Thanks for the quick response. Respectfully, I disagree. It definitely is necessary to have for client side routing to work correctly in a headless application so I see it as a basic requirement that every application needs as far as I know. Yes, you could use a regex or In addition, the |
It’s not, though. Link fields only know about the full URL. So Craft would be doing the same URL parsing you could be doing.
Sorry, I forgot to include |
Ok. Thanks for considering. |
Description
Adds a “GraphQL Mode” setting to Link fields, with the options “Full data” and “URL only”.
“Full data” will be selected by default for new Link fields; “URL only” will be selected by default for existing Link fields (for backwards compatibility on existing GraphQL APIs).
When “Full data” is selected, Link fields will be represented in GraphQL as objects with the following sub-fields:
type
value
label
urlSuffix
target
url
elementType
elementId
elementSiteId
elementTitle
For mutating Link field values, an object will need to be passed with the following sub-fields:
type
(set to a valid link type ID, e.g.url
orentry
)value
(set to the URL or element reference tag)label
(optional)urlSuffix
(optional)Related issues