0.1.0 • Published 2 years ago
gatsby-source-mta v0.1.0
gatsby-source-mta (WIP)
Gatsby source plugin for pulling data from NYC Open Data's dataset of MTA subway stations. This project is still a work in progress, but is useable in it's current state.
Installation
In a Gatsby project directory, run the following command.
npm i gatsby-source-mtaAdd the plugin to your Gatsby project's config.
const config: GatsbyConfig = {
// ... Gatsby config
plugins: [
// ... Other plugins
"gatsby-source-mta"
],
}Usage
Returns a list of all MTA stations
graphql`
query GetAllMtaStations {
allMtaStations {
nodes {
id
name
coordinates {
lat
lng
}
lines
}
}
}
`Returns a specific station by ID:
graphql`
query GetMtaStationById ($id: String!) {
mtaStations (id: {eq: $id}) {
id
name
coordinates {
lat
lng
}
lines
}
}
`Returns all stations that have A line service:
graphql`
query GetAllMtaStations {
allMtaStations(filter: {lines: {eq: "A"}}) {
nodes {
id
name
coordinates {
lat
lng
}
lines
}
}
}
`Types
Station
type Station = {
id: string;
name: string;
coordinates: {
lat: number;
lng: number;
};
lines: string[];
}Todo
- Add unit testing
- Create separate
Linenodes and types for each line - Add bus and other transit service information
- Add plugin option for overriding dataset URL