@ioki/transitland-gql-client
v2024.1.2
Published
gql client for transitland
Downloads
12
Readme
TransitLand Graphql Client
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
- Get an API key with access to the gql api at transit.land
- 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)
- join us @ioki and make this one of your projects
- create issues and pull requests, we're happy to enhance this
Contact
ioki Mobility - @ioki_mobility
Project Link: https://github.com/ioki-mobility/transitland-gql-client