gatsby-source-swapcard
v0.0.2
Published
Swapcard source plugin for connecting Gatsby to Swapcard API
Downloads
7
Maintainers
Readme
gatsby-source-swapcard
A plugin for sourcing data from Swapcard API into your Gatsby project.
This plugin makes use of the gatsby internal API in order for you to be able to run gatsby-plugin-sharp on the available images.
See the Swapcard API Docs for more information on their APIs.
Install
npm install --save gatsby-source-swapcard
How to use
Configure the plugin in your gatsby-config.js
:
{
resolve: `gatsby-source-swapcard`,
options: {
// Swapcard API accessToken
accessToken: process.env.ACCESS_TOKEN,
// Your event id
eventId: `=====`,
},
}
To retrieve these information you need to ask Swapcard for an API token and then use it in the Playground in order to get the eventId of the event you wish. Here's an example query to get this information:
{
events {
id
title
}
}
Note: Don't forget to set the HTTP Headers into something like:
{
"Authorization": "accessToken"
}
How to Query
Depending on your accessToken and your enabled features you will be able to retrieve the following information:
- event details (
allSwapcardEvent
orswapcardEvent
) - speakers (
allSwapcardSpeakers
orswapcardSpeaker
) - planning (
allSwapcardPlanning
orswapcardPlanning
) - attendees (
allSwapcardAttendee
orswapcardAttendee
) - exhibitors (
allSwapcardExhibitor
orswapcardExhibitor
)
The available fields on each resource are the same as retrieved from the API
Whenever a resource has an associated image you can run gatsby-plugin-sharp
on
the node as the following example:
{
allSwapcardAttendee {
edges {
node {
id
lastName
firstName
localFile {
childImageSharp {
fluid(maxWidth: 600) {
src
srcSet
...
}
}
}
}
}
}
}