Mutate to create a new route
Stations and cars are fun, but it's time to take a look at routing. In this first example the basics will be explained. It will serve as a starting point for more complex routing examples.
View on Github
- Chargetrip API key - to plot routes outside this region
- Mapbox API key - to display the map
- URQL - a lightweight graphQL client
- Plotting a route starts by executing the
newRoutemutation. This mutation requires information about the car, origin and destination. After the mutation is finished executing a route
idwill be returned.
idcan be used to request route updates through the
routeUpdatedByIdsubscription. This subscription receives dynamic updates.
- After the subscription returns done as status, data can be rendered onto the screen. The
legsobject will be used to display charge stations on the map. Total distance, duration of a trip, consumption are displayed on the side.
This example provides the basis for all upcoming routing examples. More features such as alternative routes, stations along a route, preferred operators and an elevation plot will be added on top of this.