directus / gatsby-source-directus

Source plugin for pulling data into Gatsby from a Directus API.
11 stars 12 forks source link

Improvements/gatsby 5 compatibility #21

Closed mcueto closed 1 year ago

mcueto commented 1 year ago

Hi guys!

I was updating to gatsby 5 from gatsby 4 and a graphql lib dependency error ocurred(multiple versions were being installed).

What was the problem it was generating?

The dependencies were conflicting and therefore the graphql schema for directus wasn't being generated.

imagen

imagen

How did I fix it?

I just updated the dependencies in the plugin to it's 5.x versions, that fixed the problem.

Which problems still exists with this approach?

There may be breaking changes if you try to install this package on a gatsby 4 website, I tested setting the requirements as ^4 and 4 - 5 and in both cases npm was installing the last version, so no gatsby 4 compatibility and that could be an issue.

I ended up setting them as 5.2.0 which is the last stable version of both dependencies, with that it works as expected on gatsby 5.

to install it use

npm install https://github.com/mcueto/gatsby-source-directus/tarball/improvements/gatsby-5-compatibility

and then you will be able to query your schema again

imagen

Note to the maintainers

I didn't update the package version because I didn't know whats the correct version to make it not backwards compatible or how you would solve those "breaking changes" aforementioned.

Cheers!

rijkvanzanten commented 1 year ago

Should we try making the gatsby dependencies a peerDependency instead of a regular dependency so we can have the peer set to 4 / 5? 🤔 that way it's up to the project to make sure the correct versions exist for their projects and we can keep our package backwards compatible

mcueto commented 1 year ago

Ok I will try that and then tell you what is the outcome

mcueto commented 1 year ago

Added as peerDependency and tested on gatsby 4 and 5.

I also added some instructions to the readme.md file in order to let the users know what to do when installing for both versions.

(ps: I Think the readme file must be renamed to README.md.

Running on gatsby 4

imagen

Running on gatsby 5

imagen

mcueto commented 1 year ago

Hi @freekrai please approve the workflow when possible, I have been testing gatsby 5 + the Slices API + directus and it works! :partying_face:

freekrai commented 1 year ago

I'll be looking over this PR this week, also want to make sure the plug-in continues to work for 4 users as well so will be testing and posting comments

msalmeron commented 1 year ago

Hi! @freekrai there's any issue or concern regarding this PR not being approved yet? We've ongoing projects that will benefit from this, now as a workaround, we are installing the plugin directly from @mcueto fork Thanks!

msalmeron commented 1 year ago

Sorry to bother you here again here, but can be the npm package updated to include these changes?

rijkvanzanten commented 1 year ago

Sorry to bother you here again here, but can be the npm package updated to include these changes?

Yes! Going up now 👍🏻