Git Product home page Git Product logo

Comments (2)

CMeeg avatar CMeeg commented on July 4, 2024

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.

  1. Currently, the plugin adds collections, nodes and references to the GraphQL data layer using the data store API and Gridsome infers the types that need to be added to the GraphQL schema based on the shape of the nodes. This is why you get build errors if the plugin doesn't attempt to add any data (e.g. when there is no published content) as the schema will be undefined.

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.

  1. Following on from the above, the schema API was added in Gridsome 0.7, which was later than when I was doing the initial development on this plugin, which was all on 0.6. Adding schema resolvers used to be a part of the data store API, but apart from that you had little direct control over the schema itself. That has now changed with the schema API and I think a better, long-term fix would be to modify the plugin to make more extensive use of the schema API. Instead of inferring the schema it would be possible to define the schema based on the content types of your Kontent project, and by directly defining types for things like assets and taxonomy.

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):

  • Clone this repo
  • Execute yarn link in the root of the repo
  • Create / use an existing Gridsome project that will use this plugin and can be used for testing
    • I use my blog (which I still haven't completed!), but have also just spun up a new Gridsome site and used a Kontent starter site in the past too
  • Execute yarn link "@meeg/gridsome-source-kentico-kontent" in my test project so that my local version of the plugin is used rather than the package from npm in node_modules
  • Start a new feature branch in the plugin repo and do some work
  • Test my work in the Gridsome project

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.

from gridsome-source-kentico-kontent.

CMeeg avatar CMeeg commented on July 4, 2024

A fix for both of the errors reported has been included in 0.4.1.

from gridsome-source-kentico-kontent.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.