{"componentChunkName":"component---src-templates-developers-js","path":"/en/developers/apis/1-routing-api/0-graphql/","result":{"data":{"childPages":{"edges":[{"node":{"fields":{"slug":"/en/developers/"},"frontmatter":{"title":"For developers","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/architecture/"},"frontmatter":{"title":"System architecture","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/api-registration/"},"frontmatter":{"title":"API portal and registration","order":-12,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/changes/"},"frontmatter":{"title":"Changes","order":-10,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/user-interfaces/"},"frontmatter":{"title":"User interfaces","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/deprecations/"},"frontmatter":{"title":"Deprecations","order":-11,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/docker-guide/"},"frontmatter":{"title":"Docker guide","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/"},"frontmatter":{"title":"APIs","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/"},"frontmatter":{"title":"Routing API","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/2-routing-data-api/"},"frontmatter":{"title":"Routing data API","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/4-map-api/"},"frontmatter":{"title":"Map API","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/architecture/x-apis/"},"frontmatter":{"title":"API architecture","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/6-api-faq/"},"frontmatter":{"title":"FAQ","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/5-realtime-api/"},"frontmatter":{"title":"Realtime APIs","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/3-geocoding-api/"},"frontmatter":{"title":"Geocoding API","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/7-terms-of-use/"},"frontmatter":{"title":"Terms of use","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/user-interfaces/1-digitransit-ui/"},"frontmatter":{"title":"Digitransit-ui","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/0-graphql/"},"frontmatter":{"title":"GraphQL","order":10,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/3-realtime-information/"},"frontmatter":{"title":"Real-time information","order":40,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/2-glossary/"},"frontmatter":{"title":"Glossary","order":30,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/canceled-trips/"},"frontmatter":{"title":"Canceled trips","order":80,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/disruption-info/"},"frontmatter":{"title":"Disruption info","order":70,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/4-translations/"},"frontmatter":{"title":"Translation","order":50,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/routes/"},"frontmatter":{"title":"Routes","order":100,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/stops/"},"frontmatter":{"title":"Stops","order":110,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/bicycles-scooters-cars/"},"frontmatter":{"title":"Bicycles, cars and e-scooters","order":60,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/itinerary-planning/"},"frontmatter":{"title":"Itinerary planning","order":90,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/architecture/x-apis/1-routing-api/"},"frontmatter":{"title":"Routing API","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/architecture/x-apis/2-routing-data-api/"},"frontmatter":{"title":"Routing Data","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/architecture/x-apis/4-map-api/"},"frontmatter":{"title":"Map API","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/architecture/x-apis/5-realtime-api/"},"frontmatter":{"title":"Real-time APIs","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/architecture/x-apis/3-geocoding-api/"},"frontmatter":{"title":"Geocoding API","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/1-routing-api/1-graphiql/"},"frontmatter":{"title":"GraphiQL","order":20,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/4-map-api/background-map/"},"frontmatter":{"title":"Background map","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/5-realtime-api/1-getting-started/"},"frontmatter":{"title":"Getting started","order":10,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/3-geocoding-api/address-search/"},"frontmatter":{"title":"Address search","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/3-geocoding-api/autocomplete/"},"frontmatter":{"title":"Autocomplete","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/5-realtime-api/trip-updates/"},"frontmatter":{"title":"Trip updates","order":30,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/5-realtime-api/service-alerts/"},"frontmatter":{"title":"Service alerts","order":20,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/3-geocoding-api/address-lookup/"},"frontmatter":{"title":"Address lookup","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/4-map-api/pois/"},"frontmatter":{"title":"Points of interest","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/5-realtime-api/vehicle-positions/"},"frontmatter":{"title":"Vehicle positions","order":40,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/architecture/x-apis/3-geocoding-api/data-container/"},"frontmatter":{"title":"Data builder and container","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/architecture/x-apis/3-geocoding-api/api/"},"frontmatter":{"title":"API","order":null,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/5-realtime-api/vehicle-positions/high-frequency-positioning/"},"frontmatter":{"title":"High-frequency positioning","order":20,"redirect":null}}},{"node":{"fields":{"slug":"/en/developers/apis/5-realtime-api/vehicle-positions/digitransit-mqtt/"},"frontmatter":{"title":"Digitransit MQTT broker","order":10,"redirect":null}}}]},"markdownRemark":{"fields":{"slug":"/en/developers/apis/1-routing-api/0-graphql/"},"frontmatter":{"title":"GraphQL","redirect":null,"toc":null,"description":null,"assets":null,"technologies":null,"docker":null},"html":"<h2 id=\"what-is-graphql\" style=\"position:relative;\"><a href=\"#what-is-graphql\" aria-label=\"what is graphql permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is GraphQL?</h2>\n<p><a href=\"http://graphql.org/\">GraphQL</a> is a query language for APIs and a runtime for fulfilling those queries with your existing data. The standard was created by Facebook. Basically, you can think of it as “client side SQL”. When implementing a GraphQL API, server developers specify a GraphQL schema that defines what can be queried. Instead of the client calling REST-like urls, it generates different GraphQL queries and sends these queries to the single endpoint of the API. The server then parses the query, executes it, and returns the results back to client.</p>\n<h2 id=\"using-graphql\" style=\"position:relative;\"><a href=\"#using-graphql\" aria-label=\"using graphql permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Using GraphQL</h2>\n<h3 id=\"creating-and-sending-queries\" style=\"position:relative;\"><a href=\"#creating-and-sending-queries\" aria-label=\"creating and sending queries permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Creating and sending queries</h3>\n<p>Queries are written in GraphQL language and sent to the API in request body of a <strong>HTTP POST</strong> request with either <code class=\"language-text\">\"application/graphql\"</code> or <code class=\"language-text\">\"application/json\"</code> as <em>Content-Type</em>.\n<br/>Queries define what type of data and what fields of the data are requested.\n<br/>The API returns a result corresponding to the query in <strong>JSON</strong> format.</p>\n<p>The following queries would request a stop with id <code class=\"language-text\">HSL:1173434</code> and return its name and coordinates:</p>\n<ul>\n<li>Using <code class=\"language-text\">Content-Type: \"application/graphql\"</code>:</li>\n</ul>\n<div class=\"gatsby-highlight\" data-language=\"graphql\"><pre class=\"language-graphql\"><code class=\"language-graphql\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property-query\">stop</span><span class=\"token punctuation\">(</span><span class=\"token attr-name\">id</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"HSL:1173434\"</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token property\">name</span>\n    <span class=\"token property\">lat</span>\n    <span class=\"token property\">lon</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<ul>\n<li>Using <code class=\"language-text\">Content-Type: \"application/json\"</code></li>\n</ul>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property\">\"query\"</span><span class=\"token operator\">:</span> \"<span class=\"token punctuation\">{</span>\n    stop(id<span class=\"token operator\">:</span> \\\"HSL<span class=\"token operator\">:</span><span class=\"token number\">1173434</span>\\\") <span class=\"token punctuation\">{</span>\n      name\n      lat\n      lon\n    <span class=\"token punctuation\">}</span>\"\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p><strong>Example response:</strong></p>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property\">\"data\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token property\">\"stop\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Asemapäällikönkatu\"</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"lat\"</span><span class=\"token operator\">:</span> <span class=\"token number\">60.199135</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"lon\"</span><span class=\"token operator\">:</span> <span class=\"token number\">24.94007</span>\n    <span class=\"token punctuation\">}</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<h3 id=\"ids\" style=\"position:relative;\"><a href=\"#ids\" aria-label=\"ids permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>IDs</h3>\n<p>Some objects in the GraphQL API have a global ID (field <code class=\"language-text\">id</code>), which can be used as a cache key or to refetch the object using query type <strong>node</strong>.</p>\n<p>Global IDs in the Routing API are defined by <a href=\"https://facebook.github.io/relay/graphql/objectidentification.htm\">Relay</a> and should not be confused with other IDs (such as <code class=\"language-text\">gtfsId</code>) that objects may have.</p>\n<h3 id=\"interfaces\" style=\"position:relative;\"><a href=\"#interfaces\" aria-label=\"interfaces permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Interfaces</h3>\n<p>GraphQL supports interfaces, which objects can implement by including fields required by the interface.</p>\n<p>If a query type returns an interface, <a href=\"https://graphql.org/learn/queries/#inline-fragments\">inline fragments</a> have to be used to access fields defined by the object implementing the interface.</p>\n<p>For example, query type <strong>nearest</strong> returns a list of <strong>PlaceInterfaces</strong> and types <strong>VehicleParking</strong> and <strong>Stop</strong> implement <strong>PlaceInterface</strong>.<br/>\nThe following query returns field <code class=\"language-text\">spacesAvailable</code> for bike parks and field <code class=\"language-text\">code</code> for stops.</p>\n<div class=\"gatsby-highlight\" data-language=\"graphql\"><pre class=\"language-graphql\"><code class=\"language-graphql\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property-query\">nearest</span><span class=\"token punctuation\">(</span><span class=\"token attr-name\">lat</span><span class=\"token punctuation\">:</span> <span class=\"token number\">60.19414</span><span class=\"token punctuation\">,</span> <span class=\"token attr-name\">lon</span><span class=\"token punctuation\">:</span> <span class=\"token number\">25.02965</span><span class=\"token punctuation\">,</span> <span class=\"token attr-name\">maxResults</span><span class=\"token punctuation\">:</span> <span class=\"token number\">3</span><span class=\"token punctuation\">,</span> <span class=\"token attr-name\">maxDistance</span><span class=\"token punctuation\">:</span> <span class=\"token number\">1500</span><span class=\"token punctuation\">,</span> <span class=\"token attr-name\">filterByPlaceTypes</span><span class=\"token punctuation\">:</span> <span class=\"token punctuation\">[</span><span class=\"token constant\">STOP</span><span class=\"token punctuation\">,</span> <span class=\"token constant\">BIKE_PARK</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token object\">edges</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token object\">node</span> <span class=\"token punctuation\">{</span>\n          <span class=\"token object\">place</span> <span class=\"token punctuation\">{</span>\n            <span class=\"token property\">lat</span>\n            <span class=\"token property\">lon</span>\n            <span class=\"token operator\">...</span><span class=\"token keyword\">on</span> <span class=\"token class-name\">Stop</span> <span class=\"token punctuation\">{</span>\n              <span class=\"token property\">name</span>\n              <span class=\"token property\">gtfsId</span>\n              <span class=\"token property\">code</span>\n            <span class=\"token punctuation\">}</span>\n            <span class=\"token operator\">...</span><span class=\"token keyword\">on</span> <span class=\"token class-name\">VehicleParking</span> <span class=\"token punctuation\">{</span>\n              <span class=\"token property\">vehicleParkingId</span>\n              <span class=\"token property\">name</span>\n              <span class=\"token property\">bicyclePlaces</span>\n            <span class=\"token punctuation\">}</span>\n          <span class=\"token punctuation\">}</span>\n          <span class=\"token property\">distance</span>\n      <span class=\"token punctuation\">}</span>\n    <span class=\"token punctuation\">}</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<h3 id=\"variables\" style=\"position:relative;\"><a href=\"#variables\" aria-label=\"variables permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Variables</h3>\n<p>For more complex queries, variables can be useful.<br/>\nTo use variables, queries must be sent with Content-Type <strong>application/json</strong> and the query must have an operation name.</p>\n<p>Variables are sent in a JSON object with key <code class=\"language-text\">variables</code>.</p>\n<p>For example, the following query would request a route with name <code class=\"language-text\">550</code> (using <em>Routes</em> as an operation name):</p>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property\">\"query\"</span><span class=\"token operator\">:</span> \"query Routes($name<span class=\"token operator\">:</span> String) <span class=\"token punctuation\">{</span>\n             routes(name<span class=\"token operator\">:</span> $name) <span class=\"token punctuation\">{</span>\n               gtfsId\n               shortName\n               longName\n             <span class=\"token punctuation\">}</span>\n           <span class=\"token punctuation\">}</span>\"<span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"variables\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span><span class=\"token string\">\"550\"</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<h3 id=\"pagination\" style=\"position:relative;\"><a href=\"#pagination\" aria-label=\"pagination permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Pagination</h3>\n<ul>\n<li>Query types which support pagination can be used without pagination by omitting arguments <code class=\"language-text\">first</code> and <code class=\"language-text\">after</code>, in which case all data is returned on one page</li>\n</ul>\n<p>Some query types support pagination, which can be used to limit the amount of data returned per query.\n<br/>Query types which support pagination return a <a href=\"https://relay.dev/graphql/connections.htm\">Relay cursor connection</a> to the data.</p>\n<p>For example, <strong>stopsByRadius</strong> supports pagination. The following query requests stops within 300m of 60.19924, 24.94112 and returns 2 stops per page (argument <code class=\"language-text\">first</code>).</p>\n<div class=\"gatsby-highlight\" data-language=\"graphql\"><pre class=\"language-graphql\"><code class=\"language-graphql\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property-query\">stopsByRadius</span><span class=\"token punctuation\">(</span><span class=\"token attr-name\">lat</span><span class=\"token punctuation\">:</span> <span class=\"token number\">60.19924</span><span class=\"token punctuation\">,</span> <span class=\"token attr-name\">lon</span><span class=\"token punctuation\">:</span> <span class=\"token number\">24.94112</span><span class=\"token punctuation\">,</span> <span class=\"token attr-name\">radius</span><span class=\"token punctuation\">:</span> <span class=\"token number\">300</span><span class=\"token punctuation\">,</span> <span class=\"token attr-name\">first</span><span class=\"token punctuation\">:</span> <span class=\"token number\">2</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token object\">edges</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token object\">node</span> <span class=\"token punctuation\">{</span>\n        <span class=\"token object\">stop</span> <span class=\"token punctuation\">{</span>\n          <span class=\"token property\">name</span>\n          <span class=\"token property\">lat</span>\n          <span class=\"token property\">lon</span>\n        <span class=\"token punctuation\">}</span>\n        <span class=\"token property\">distance</span>\n      <span class=\"token punctuation\">}</span>\n      <span class=\"token property\">cursor</span>\n    <span class=\"token punctuation\">}</span>\n    <span class=\"token object\">pageInfo</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token property\">hasNextPage</span>\n      <span class=\"token property\">endCursor</span>\n    <span class=\"token punctuation\">}</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>An example response:</p>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property\">\"data\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token property\">\"stopsByRadius\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token property\">\"edges\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\n        <span class=\"token punctuation\">{</span>\n          <span class=\"token property\">\"node\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n            <span class=\"token property\">\"stop\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n              <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Asemapäällikönkatu\"</span><span class=\"token punctuation\">,</span>\n              <span class=\"token property\">\"lat\"</span><span class=\"token operator\">:</span> <span class=\"token number\">60.199135</span><span class=\"token punctuation\">,</span>\n              <span class=\"token property\">\"lon\"</span><span class=\"token operator\">:</span> <span class=\"token number\">24.94007</span>\n            <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n            <span class=\"token property\">\"distance\"</span><span class=\"token operator\">:</span> <span class=\"token number\">136</span>\n          <span class=\"token punctuation\">}</span>\n        <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n        <span class=\"token punctuation\">{</span>\n          <span class=\"token property\">\"node\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n            <span class=\"token property\">\"stop\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n              <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Ratamestarinkatu\"</span><span class=\"token punctuation\">,</span>\n              <span class=\"token property\">\"lat\"</span><span class=\"token operator\">:</span> <span class=\"token number\">60.198534</span><span class=\"token punctuation\">,</span>\n              <span class=\"token property\">\"lon\"</span><span class=\"token operator\">:</span> <span class=\"token number\">24.939466</span>\n            <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n            <span class=\"token property\">\"distance\"</span><span class=\"token operator\">:</span> <span class=\"token number\">285</span>\n          <span class=\"token punctuation\">}</span>\n        <span class=\"token punctuation\">}</span>\n      <span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"pageInfo\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n        <span class=\"token property\">\"hasNextPage\"</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span><span class=\"token punctuation\">,</span>\n        <span class=\"token property\">\"endCursor\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"c2ltcGxlLWN1cnNvcjE=\"</span>\n      <span class=\"token punctuation\">}</span>\n    <span class=\"token punctuation\">}</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>The field <code class=\"language-text\">hasNextPage</code> indicates whether all data has been returned or not.\n<br />If <code class=\"language-text\">hasNextPage</code> is <code class=\"language-text\">true</code>, the next page can be queried by using the value of <code class=\"language-text\">endCursor</code> for argument <code class=\"language-text\">after</code> in the query.</p>\n<p>For example, the following query returns the next page of data:</p>\n<div class=\"gatsby-highlight\" data-language=\"graphql\"><pre class=\"language-graphql\"><code class=\"language-graphql\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property-query\">stopsByRadius</span><span class=\"token punctuation\">(</span><span class=\"token attr-name\">lat</span><span class=\"token punctuation\">:</span> <span class=\"token number\">60.19924</span><span class=\"token punctuation\">,</span> <span class=\"token attr-name\">lon</span><span class=\"token punctuation\">:</span> <span class=\"token number\">24.94112</span><span class=\"token punctuation\">,</span> <span class=\"token attr-name\">radius</span><span class=\"token punctuation\">:</span> <span class=\"token number\">300</span><span class=\"token punctuation\">,</span> <span class=\"token attr-name\">first</span><span class=\"token punctuation\">:</span> <span class=\"token number\">2</span><span class=\"token punctuation\">,</span> <span class=\"token attr-name\">after</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"c2ltcGxlLWN1cnNvcjE=\"</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token object\">edges</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token object\">node</span> <span class=\"token punctuation\">{</span>\n        <span class=\"token object\">stop</span> <span class=\"token punctuation\">{</span>\n          <span class=\"token property\">name</span>\n          <span class=\"token property\">lat</span>\n          <span class=\"token property\">lon</span>\n        <span class=\"token punctuation\">}</span>\n        <span class=\"token property\">distance</span>\n      <span class=\"token punctuation\">}</span>\n    <span class=\"token punctuation\">}</span>\n    <span class=\"token object\">pageInfo</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token property\">hasNextPage</span>\n      <span class=\"token property\">endCursor</span>\n    <span class=\"token punctuation\">}</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>An example response:</p>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property\">\"data\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token property\">\"stopsByRadius\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token property\">\"edges\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\n        <span class=\"token punctuation\">{</span>\n          <span class=\"token property\">\"node\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n            <span class=\"token property\">\"stop\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n              <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Kellosilta\"</span><span class=\"token punctuation\">,</span>\n              <span class=\"token property\">\"lat\"</span><span class=\"token operator\">:</span> <span class=\"token number\">60.20068</span><span class=\"token punctuation\">,</span>\n              <span class=\"token property\">\"lon\"</span><span class=\"token operator\">:</span> <span class=\"token number\">24.93897</span>\n            <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n            <span class=\"token property\">\"distance\"</span><span class=\"token operator\">:</span> <span class=\"token number\">293</span>\n          <span class=\"token punctuation\">}</span>\n        <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n        <span class=\"token punctuation\">{</span>\n          <span class=\"token property\">\"node\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n            <span class=\"token property\">\"stop\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n              <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Pasilan asema\"</span><span class=\"token punctuation\">,</span>\n              <span class=\"token property\">\"lat\"</span><span class=\"token operator\">:</span> <span class=\"token number\">60.198626</span><span class=\"token punctuation\">,</span>\n              <span class=\"token property\">\"lon\"</span><span class=\"token operator\">:</span> <span class=\"token number\">24.937843</span>\n            <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n            <span class=\"token property\">\"distance\"</span><span class=\"token operator\">:</span> <span class=\"token number\">294</span>\n          <span class=\"token punctuation\">}</span>\n        <span class=\"token punctuation\">}</span>\n      <span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"pageInfo\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n        <span class=\"token property\">\"hasNextPage\"</span><span class=\"token operator\">:</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">,</span>\n        <span class=\"token property\">\"endCursor\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"c2ltcGxlLWN1cnNvcjM=\"</span>\n      <span class=\"token punctuation\">}</span>\n    <span class=\"token punctuation\">}</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<h3 id=\"graphql-clients\" style=\"position:relative;\"><a href=\"#graphql-clients\" aria-label=\"graphql clients permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>GraphQL clients</h3>\n<p>In most cases, a GraphQL client should be used instead of plain HTTP requests, as GraphQL clients have many useful features (such as caching, batching and validating queries), which would otherwise have to be implemented manually.</p>\n<p>Two commonly used GraphQL clients are</p>\n<ul>\n<li><a href=\"https://relay.dev/\">Relay</a> by Facebook, supports React</li>\n<li><a href=\"https://www.apollographql.com/\">Apollo</a>, supports multiple development platforms, including Android and iOS</li>\n</ul>\n<h3 id=\"graphql-schema\" style=\"position:relative;\"><a href=\"#graphql-schema\" aria-label=\"graphql schema permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>GraphQL schema</h3>\n<p>The current development version of the schema is available <a href=\"https://raw.githubusercontent.com/HSLdevcom/OpenTripPlanner/refs/heads/v2/application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls\">here</a>. It might not always match the production version completely. The production schema can be accessed either by browsing the files from our latest <a href=\"https://github.com/HSLdevcom/OpenTripPlanner/releases\">release in Github</a> or by running <a href=\"https://api.digitransit.fi/graphiql/hsl/v2/gtfs/v1?query=query%2520IntrospectionQuery%2520%257B%250A%2520%2520__schema%2520%257B%250A%2520%2520%2520%2520queryType%2520%257B%250A%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520mutationType%2520%257B%250A%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520subscriptionType%2520%257B%250A%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520types%2520%257B%250A%2520%2520%2520%2520%2520%2520...FullType%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520directives%2520%257B%250A%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520description%250A%2520%2520%2520%2520%2520%2520locations%250A%2520%2520%2520%2520%2520%2520args%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520...InputValue%250A%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%257D%250A%2520%2520%257D%250A%257D%250A%250Afragment%2520FullType%2520on%2520__Type%2520%257B%250A%2520%2520kind%250A%2520%2520name%250A%2520%2520description%250A%2520%2520fields%28includeDeprecated%253A%2520true%29%2520%257B%250A%2520%2520%2520%2520name%250A%2520%2520%2520%2520description%250A%2520%2520%2520%2520args%2520%257B%250A%2520%2520%2520%2520%2520%2520...InputValue%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520type%2520%257B%250A%2520%2520%2520%2520%2520%2520...TypeRef%250A%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520isDeprecated%250A%2520%2520%2520%2520deprecationReason%250A%2520%2520%257D%250A%2520%2520inputFields%2520%257B%250A%2520%2520%2520%2520...InputValue%250A%2520%2520%257D%250A%2520%2520interfaces%2520%257B%250A%2520%2520%2520%2520...TypeRef%250A%2520%2520%257D%250A%2520%2520enumValues%28includeDeprecated%253A%2520true%29%2520%257B%250A%2520%2520%2520%2520name%250A%2520%2520%2520%2520description%250A%2520%2520%2520%2520isDeprecated%250A%2520%2520%2520%2520deprecationReason%250A%2520%2520%257D%250A%2520%2520possibleTypes%2520%257B%250A%2520%2520%2520%2520...TypeRef%250A%2520%2520%257D%250A%257D%250A%250Afragment%2520InputValue%2520on%2520__InputValue%2520%257B%250A%2520%2520name%250A%2520%2520description%250A%2520%2520type%2520%257B%250A%2520%2520%2520%2520...TypeRef%250A%2520%2520%257D%250A%2520%2520defaultValue%250A%257D%250A%250Afragment%2520TypeRef%2520on%2520__Type%2520%257B%250A%2520%2520kind%250A%2520%2520name%250A%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520kind%250A%2520%2520%2520%2520name%250A%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520ofType%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520kind%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520name%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%257D%250A%2520%2520%257D%250A%257D%250A&#x26;operationName=IntrospectionQuery\">this example in GraphQL console</a></p>\n<h2 id=\"further-reading\" style=\"position:relative;\"><a href=\"#further-reading\" aria-label=\"further reading permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Further reading</h2>\n<ul>\n<li>The <a href=\"https://graphql.org/learn/\">GraphQL site</a> provides more information on how to use GraphQL</li>\n<li><a href=\"https://relay.dev/docs/principles-and-architecture/thinking-in-graphql/\">Thinking in GraphQL</a></li>\n</ul>","tableOfContents":"<ul>\n<li><a href=\"/en/developers/apis/1-routing-api/0-graphql/#what-is-graphql\">What is GraphQL?</a></li>\n<li>\n<p><a href=\"/en/developers/apis/1-routing-api/0-graphql/#using-graphql\">Using GraphQL</a></p>\n<ul>\n<li><a href=\"/en/developers/apis/1-routing-api/0-graphql/#creating-and-sending-queries\">Creating and sending queries</a></li>\n<li><a href=\"/en/developers/apis/1-routing-api/0-graphql/#ids\">IDs</a></li>\n<li><a href=\"/en/developers/apis/1-routing-api/0-graphql/#interfaces\">Interfaces</a></li>\n<li><a href=\"/en/developers/apis/1-routing-api/0-graphql/#variables\">Variables</a></li>\n<li><a href=\"/en/developers/apis/1-routing-api/0-graphql/#pagination\">Pagination</a></li>\n<li><a href=\"/en/developers/apis/1-routing-api/0-graphql/#graphql-clients\">GraphQL clients</a></li>\n<li><a href=\"/en/developers/apis/1-routing-api/0-graphql/#graphql-schema\">GraphQL schema</a></li>\n</ul>\n</li>\n<li><a href=\"/en/developers/apis/1-routing-api/0-graphql/#further-reading\">Further reading</a></li>\n</ul>","excerpt":"What is GraphQL? GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. The standard was created by Facebook. Basically, you can think of it as…"}},"pageContext":{"slug":"/en/developers/apis/1-routing-api/0-graphql/"}},"staticQueryHashes":["3675773199","4050193485"]}