danspratling / gatsby-source-multi-api

Allows data sourced from one or more rest api to be imported into a GatsbyJS project
12 stars 8 forks source link

Extending data fetch functionality #7

Closed danspratling closed 4 years ago

danspratling commented 4 years ago

Currently, the plugin only accepts endpoints, however this isn't enough to be able to properly fetch all data requirements. This post is to establish all the requirements which may be needed when an endpoint is requested.

Some which i've thought of or have come up in other discussion [] authentication [] multiple endpoints from the same source (/posts, /pages) [] method (within reason - we'll never send data, just requiest it)

Anything else which might be useful?

danspratling commented 4 years ago

Changes are being made on rc1.0.0. Any feedback so far or suggested improvements are very welcome!

danspratling commented 4 years ago

Updates

Authentication was abandoned due to the ability for this to be set up pretty much however the developer wants. As I can't guess which API might be used, i can't ensure i'll be able to authenticate properly either.

Multiple endpoints has been added using a baseUrl + endpoint approach. This means that you'll be able to get results from all endpoints you wish from a service without having to get any extra endpoints (making your GraphQL experience much cleaner & easier).

Method has been added as an additional option.

Prefix has been added as an additional option so if you wish you can customize the GraphQL node name. allRestApi (or as the new version will be, allMultiApiSource works, but it doesn't really tell you what service it is that's being called, meaning you'd have to dig through the nodes to figure it out. Now you can name it whatever you want so you know which nodes are SpaceX and which nodes are OpenWeather (or whatever you choose).

The nodes are also very flexible. If you just want to list endpoints you can list the strings. If you want more control you can do so by supplying the object.

Breaking changes

The name of the plugin has changed. The focus is now more on the fact that multiple api's can be handled at once than the fact that RestAPIs can be handled (as strictly, this can handle any json api). This means that the plugin will need to be re-installed. gatsby-source-rest-api will still exist as a node package for a short time. The new plugin will be called gatsby-source-multi-api.

This plugin also no longer accepts a single api in the form of a string. the apis option must now be an array - though that array can contain only 1 option if you so wish.

danspratling commented 4 years ago

Updates have been deployed. Legacy code has been marked as such. A new plugin has been published with the new name, but the old one still exists (though has been deprecated).