Closed idesignzone closed 3 years ago
I don't got time today, but I'll definitely take a look at it.
How do you fetch the graphql api (axois, fetch, apollo...)? I tried around a bit and for me it came down to a cors
issue.
This is pretty strange and I am not sure how to debug this. but this is the situation: I use Gridsome in front. When I build the app, building process pauses when it gets to sidebar query, During this pause I try to open live website and it gives me a database connection error, then build fails with 500 error. It seems the sidebar query breaks the database connection and fails.
Are you using @gridsome/source-graphql
to query? Which wp-graphql version are you on? How are building, on your local machine (from the live server)?
Are you using
@gridsome/source-graphql
to query? Which wp-graphql version are you on? How are building, on your local machine (from the live server)?
yes I use @gridsome/source-graphql
and latest version of WPGraphQL.
I just place the live website URL (process.env.WORDPRESS_URL)
plugins: [
{
use: '@gridsome/source-graphql',
options: {
url: (process.env.WORDPRESS_URL) + "/graphql",
fieldName: 'WordPress',
typeName: '',
// headers: {
// Authorization: `Bearer ${process.env.AUTH_TOKEN}`,
// },
},
},
{
use: 'gridsome-plugin-uikit'
}
],
Yeah that's indeed pretty strange. I just ran a gridsome build on my local machine with a live server, for me it worked just fine (just some posts and a basic sidebar). Do you maybe have any not standart widgets?
Could it also be that a query before the sidebar query breaks, which causes the break of the database connection, and then leads to the 500 in the sidebar query?
Could it also be that a query before the sidebar query breaks, which causes the break of the database connection, and then leads to the 500 in the sidebar query?
Project is pretty big with many queries. I will try to query one by one to hopefully find the query that breaks the connection. Really appreciate your help. This plugin is great and you are awesome. I will update my investigation here. Thanks again.
I could also send you the repo I created (and used) to test.
How do you fetch the graphql api (axois, fetch, apollo...)? I tried around a bit and for me it came down to a
cors
issue.
How did you manage to fix cors problem?
For fetch
(and apollo
in the frontend) with credentials: "omit"
. But since @gridsome/source-graphql
uses apollo
and node-fetch
it shouldn't be a problem because credentials
is not implemented in node-fetch
(https://github.com/node-fetch/node-fetch#class-request).
I can still develop and build the project locally but I found it difficult to debug 500 error . Build is breaking the server on a sidebar query but after excluding sidebar queries I still get the error. I believe we can close this issue as it doesn't relate to this plugin. Thanks for checking on this issue.
No problem. Just out of curiosity, is gridsome develop
working with the live server as the data source?
Hello. I have been using sidebar query to get the widgets from WP. Everything works fine in the local environment and I can successfully develop and build my project. However after migrating to live server I start getting error wherever I have queried the sidebars. Error: Response not successful: Received status code 500
this is my query
I can still query sidebars and widgets in GraphQL IDE on live server but cant query it in my project. Live website is exact copy of my local website. I recreated another copy of the live website locally and everything works again. This problem happens only after going live. Wondering if you have tried the plugin in production environment. Any hints will be very helpful.