gatsby-source-mta
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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-mta

Add 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 Line nodes and types for each line
  • Add bus and other transit service information
  • Add plugin option for overriding dataset URL

Package Sidebar

Install

npm i gatsby-source-mta

Weekly Downloads

2

Version

0.1.0

License

none

Unpacked Size

4.66 kB

Total Files

7

Last publish

Collaborators

  • kitfox