Skip to content

ioki-mobility/transitland-gql-client

Repository files navigation

TransitLand Graphql Client

transitland-logo-light transitland-logo-dark

npm (scoped) size npm (downloads) github test release

About

Since the Transitland released its new and shiny GraphQL API, it is possible to query the API using GraphQL.

The client is being built using GenQL and updated hourly, if there are upstream changes.

Getting Started

First add the library and its peerDependency to your project:

  • npm

    npm i @ioki/transitland-gql-client@latest
  • yarn

    yarn add @ioki/transitland-gql-client@latest

Setup

  1. Get an API key with access to the gql api at transit.land
  2. Create a client instance:
import { createClient } from '@ioki/transitland-gql-client';

const transitlandClient = createClient({
  apiKey: "YOUR_SUPER_SECRET_API_KEY",
  fetch: fetchClient // not needed for browser and node >= v18 (and >=v16 with --experimental-fetch)
});

Usage

GenQL provides a neat converter from GraphQL to TypeScript. So you can actually just test the queries you want to use in the playground.

Mocking

Using GraphQL's strict type definitions, it is pretty easy to generate a mock server you could use during your tests. An extensive example is stored as a test.

License

Distributed under the MIT License. See LICENSE.md for more information.

Contributing (complexity, asc)

  1. join us @ioki and make this one of your projects
  2. create issues and pull requests, we're happy to enhance this

Contact

ioki logo

ioki Mobility - @ioki_mobility

Project Link: https://github.com/ioki-mobility/transitland-gql-client