Closed idmahbub closed 10 months ago
Hi @idmahbub,
Thanks for opening an issue.
Have you verified the query and variables you used in your Faust Template don't return null in the WPGraphQL GraphiQL in the WP Admin? We'll want to rule this out before we can confirm this is a Faust specific issue.
Can you please also paste the query and variables you used in your Faust template? I could test it out locally as well.
Hi @blakewilson I've only run sample code from this repo, and haven't changed it at all. I have tried Quaery graphql in this file (https://github.com/wpengine/faustjs/blob/canary/examples/next/faustwp-getting-started/wp-templates/category.js) and there are no problems.
I tried to value $uri
with the static string category/news
, and it worked, the problem boils down to the line nodeByUri(uri: $uri)
where the value $uri
is null
?
in posts?.edges.map
$uri
with string category/news
This is caused by the new update of the wp-graphql v1.17.0
downgrading to the v1.16.0
solves the issue, the problem is that the URI that is passed by parameter is now the full path http://localhost:3000/category/news/
when previously was /category/news
if you run in the GraphQL IDE the following query
query GetNodeByUri($uri: String!) {
nodeByUri(uri: $uri) {
__typename
}
}
Using the full path results into a Post (specifically the latest post of the category)
{
"uri": "http://localhost:3000/category/news"
}
Meanwhile, if you run it with this variable results in the category
{
"uri": "/category/news/"
}
Another temporary fix is to change the Component.variables
into this:
Component.variables = ({ uri }) => {
return {
...
uri: new URL(uri).pathname,
...
};
};
Not sure which side should fix it, FaustJS or wp-graphql
This could also be related to this comment: https://github.com/wp-graphql/wp-graphql/pull/2341#issuecomment-1128719980
@josephfusco and I are working on reproducing right now. 👀
Hey @idmahbub can you please provide the Faust.js WordPress Plugin version you are using and which settings you have toggled on? Thank you!
This is caused by the new update of the wp-graphql
v1.17.0
downgrading to thev1.16.0
solves the issue, the problem is that the URI that is passed by parameter is now the full pathhttp://localhost:3000/category/news/
when previously was/category/news
if you run in the GraphQL IDE the following queryquery GetNodeByUri($uri: String!) { nodeByUri(uri: $uri) { __typename } }
Using the full path results into a Post (specifically the latest post of the category)
{ "uri": "http://localhost:3000/category/news" }
Meanwhile, if you run it with this variable results in the category
{ "uri": "/category/news/" }
Another temporary fix is to change the
Component.variables
into this:Component.variables = ({ uri }) => { return { ... uri: new URL(uri).pathname, ... }; };
Not sure which side should fix it, FaustJS or wp-graphql
can be run by changing the uri value uri: new URL(uri).pathname
, but coming 2 warning in console now
Hey @idmahbub can you please provide the Faust.js WordPress Plugin version you are using and which settings you have toggled on? Thank you!
faust plugin versin in Version 6.3.2, an this the setup for me
With the Faust WordPress plugin de-activated, the term uri is relative:
With the Faust WordPress plugin active, the term uri is absolute:
I think Faust needs to fix their term link filter that rewrites the links.
@idmahbub is your "Settings > General > Site Address" setting the same as your "Settings > Faust > Front-end site URL"?
If I have both settings the same, things work.
If I change the settings to be different values, then I see the issue where Faust is making the uri an absolute link, and then nodeByUri
fails because it thinks you're trying to resolve an external URI (a path to a resource to a domain that's not the site_url()
or home_url()
)
I think this callback that replaces term links needs to be updated: https://github.com/wpengine/faustjs/blob/canary/plugins/faustwp/includes/replacement/callbacks.php#L213-L227
The post_link
callback, right above it, has the following qualifier:
if (
! is_rewrites_enabled()
|| ( function_exists( 'is_graphql_request' ) && is_graphql_request() )
) {
I believe the term_link
callback also needs the same qualifier.
If it is a graphql request, return the link as-is instead of making it an absolute link.
I've opened this PR #1616 which I believe should resolve this issue.
Reopening this as a fix has not yet been merged https://github.com/wpengine/faustjs/pull/1653
Applicable Versions
Captured