0.0.4 • Published 7 years ago

data-gov-uk-graphql v0.0.4

Weekly downloads
18
License
-
Repository
github
Last release
7 years ago

GraphQL implementation of data.gov.uk API

data source: https://data.gov.uk/data/api/.

Overview

A wraparound of various datasets provided by data.gov.uk ranging from crime data, scheduled roadwork's, to hospital information. Associated responses follow close to the raw data and are mapped into the graphql type system.

All requests are generated by relevant query parameters to the data sets such as; post code, longitude / latitude etc.

All queries are modular GraphQLObjectType’s and can be simply bolted on to any existing GraphQL Schema. Resolve data fetching functions are self contained within the modules.

Available Data Sets
  • Crime Data (monthly location based street crime stats)
  • Hospital Information (location based hospital services)
  • Pharmacy Information (local pharmacies info)
  • RoadWorks Information (existing and scheduled roadworks based on road)
  • Ferry Port Information (information on ferry ports within n miles of location)
  • Airports Information (list of airport's and codes)
Caveats

Requests are made to the data source api at data.gov.uk/api response's for some of the data sets can be slow.

Install

npm install data-gov-uk-graphql

Demo Playground

Usage

import specific required data types

import {
    CrimesType,
    HospitalsType,
    PharmacysType,
    RoadWorksType,
    FerrysType,
    AirportsType
} from 'data-gov-uk-graphql'

Add type's to the schema

const QueryType = new GraphQLObjectType({
  name: 'Query',
  description: 'The root query..',
  fields: () => ({
    crimes: CrimesType,
    hospitals: HospitalsType,
    pharmacys: PharmacysType,
    roadworks: RoadWorksType,
    airports: AirportsType,
    ferrys: FerrysType,
  }),
});

export const Schema = new GraphQLSchema({
  query: QueryType,
});

Basic Example Query

Get local pharmacy information based on a partial post code

Demo

{
  pharmacys(partial_postcode:"m21"){
    name,
    address1,
    city,
    postcode
  }
}

.

API Documentation

Crime Data

Required Request Variables
VariableTypeDescription
monthStringShorthand month jan, feb
latFloatlatitude
lngFloatlongitude
yearIntyear

Demo

{
  crimes(
    lng:-1.131592,
    lat:52.629729,
    year:2015,
    month:"jun",
  ){
    id,
    category,
    outcome_status{
      category,
      date
    },
    month,
    persistent_id,
    location_type,
    location{
      latitude,
      longitude,
      street{
        id,
        name
      }
    }
  }
}

Hospital Information

location based hospital services

Required Request Variables
VariableTypeDescription
latFloatlatitude
lngFloatlongitude

Demo

{
	hospitals(lat:53.1, lon:3.0){
        postcode,
        name,
        phone,
        organisation_code,
        website
    }
}

Pharmacy Information

local pharmacies info

Required Request Variables
VariableTypeDescription
partial_postcodeStringpartial postcode first half

Demo

{
  pharmacys(partial_postcode:"m1"){
    name,
    address1,
    city,
    postcode,
  }
}

RoadWorks Information

existing and scheduled roadworks based on road

Required Request Variables
VariableTypeDescription
roadStringroad / motorway

Demo

{
  roadworks(road:"M1"){
    traffic_management,
    status,
    start_date,
    road,
    location,
    local_authority,
    expected_delay,
    end_date,
    description
  }
}

Ferry Port Information

information on ferry ports within n miles of location

Required Request Variables
VariableTypeDescription
postcodeStringfull postcode
distanceIntwithin n miles from postcode location

Demo

{
  ferrys(postcode: "L1 0AA", distance:10){
    name,
    ospoint {
      type
      coordinates
    }
    latlong {
      type
      coordinates
    },
    distance,
    ferrycode,
    atcocode
  }
}

Airports Information

list of airport's and codes

Demo

{
  airports{
    name,
    iatacode,
    atcocode
  }
}
0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.1.1

7 years ago

0.0.1

7 years ago

0.1.0

7 years ago