Closed ChristopherJennings closed 4 years ago
Hi @ChristopherJennings I haven't had a chance to look into this in much detail unfortunately to try to repro it, but from the description of the issues you have had I think there are two things that can be looked at. I suspect the root cause is the same thing though, which is to do with the how the GraphQL schema definition for Kontent types is being created.
The plugin also uses the schema API to add a schema resolver to the Asset type. Without any asset fields being defined there will be no asset nodes added to the data layer and no asset type in the schema. The plugin attempts to add the schema resolver without checking that the Asset type exists first so I suspect that is the cause of the issue.
I started looking into this a little while back, but realised that it will be more work than I had originally thought so plan on coming back to that once I have some time to properly think about it and dedicate some time.
I don't currently have an ETA on any of this stuff, but hoping I may get some downtime during the holidays to at least kick things off. In the meantime if you do want to get involved I am definitely open to help! Perhaps looking at route 1 may be a good starting point. You can use the data store API to check if a type (collection) exists.
In terms of developing on the plugin, this is what I would do (based on my current setup):
node_modules
Tbh, I am fairly new to Gridsome plugin development too! The setup works pretty well (I really like yarn link
), but debugging can be a bit of a pain. I still need to look into getting the vscode debugger involved (Ondrej was showing me how he did that on the Gatsby plugin) and sometimes I have to resort to console.log
. I am also going to be adding Jest tests when I do the schema work - I wish I had done that from the start!
Hope that helps, and thanks for getting in touch - let me know how you get on, and if you have no luck I will address this issue as soon as I can.
A fix for both of the errors reported has been included in 0.4.1.
I found that when I try to connect to a project with nothing published (I forgot that this was the case) I got this error:
Once I realized that I had nothing published, I went ahead and published a bunch of things. This got rid of the above error, but then I got this error:
This turned out to be because my types didn't have any asset fields. Once I added an asset field the above was resolved. I think it got this far because I had referenced assets in rich text fields. If I didn't have those I think I would have seen the first error again.
As near as I can tell this has to do with how the Asset resolver is loaded. I think it works fine when an Asset type resolver is added because of an asset field, but if there isn't one because there's no field or asset referenced it throws an error.
I'm still super new to Gridsome plugin development, but if you could point me in the right direction as to how to develop this and some resources to start figuring out how to resolve the asset issues, I'd be happy to give it a shot.