Develop with GraphQL
GraphQL is a query language for APIs. A REST API has a separate endpoint for each resource, so you often make several calls to collect related data. A GraphQL API has one endpoint, and you request exactly the fields you need in a single query.
Your GraphQL endpoint is https://tenant-name.is.here.io/here/api/graphql
For example, a REST API might need three calls:
GET /users/123
GET /users/123/posts
GET /posts/456/comments
A GraphQL API needs one query:
query {
user(id: "123") {
name
email
posts {
title
comments {
text
author
}
}
}
}
This example is generic. It doesn't reflect HERE APIs.
Schema
The schema defines the queries, mutations, and types that an API supports. Use introspection to read the HERE schema.
Introspection
Introspection queries ask the API to describe itself: its types, fields, queries, and mutations. Introspection fields begin with two underscores:
__schemareturns the whole schema.__type(name: String!)returns one type.__typenamereturns the name of the current object's type.
List every type:
query {
__schema {
types {
name
kind
description
}
}
}
List the fields of one type:
query {
__type(name: "User") {
name
kind
fields {
name
type {
name
kind
}
description
}
}
}
List every query and its arguments:
query {
__schema {
queryType {
name
fields {
name
args {
name
type {
name
}
}
}
}
mutationType {
name
}
subscriptionType {
name
}
}
}
HERE GraphQL APIs
- Entitlements: query content, users, groups, and roles.
- Content configuration: create, update, and delete content.
- User group management: add users to groups and remove users from groups.