Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"path": "zsh",
"args": ["-l"],
"env": {
"DHL_API_KEY": "",
"APOLLO_KEY": "",
"APOLLO_GRAPH_REF": ""
}
Expand Down
37 changes: 37 additions & 0 deletions connectors/dhl/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# DHL REST Connector

This connector currently covers the [Tracking object](https://developer.dhl.com/api-reference/shipment-tracking) in the [DHL REST API](https://developer.dhl.com/). To use this, you'll need to add a `DHL_API_KEY` in your environment variables when running `rover` or the `router` with the config files in this folder.

## Additional Setup for VS Code Task Runner

Edit your `.vscode/settings.json` to include the DHL-specific keys:

```json
{
"terminal.integrated.profiles.osx": {
"graphos": {
"path": "zsh",
"args": ["-l"],
"env": {
"DHL_API_KEY": "",
"APOLLO_KEY": "",
...
}
}
},
"terminal.integrated.defaultProfile.osx": "graphos"
}


---

Then you can execute the "Tasks: Run Task" command in VS code to execute the `rover dev` task or simply open a new terminal window in vscode with the `graphos` profile, then you can simply run `rover dev --supergraph-config supergraph.yaml --router-config router.yaml`.

## Contributing

The following schema modules need to include:

1. A schema designed for that portion of the rest API as a new `.graphql` file
2. Additions to the `router.yaml` and `supergraph.yaml` files

You can view the DHL API Catalog for other modules to implement. [https://developer.dhl.com/api-reference/shipment-tracking#get-started-section/]
76 changes: 76 additions & 0 deletions connectors/dhl/dhl-tracking.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.10", import: ["@key", "@requires"])
@link(
url: "https://specs.apollo.dev/connect/v0.1"
import: ["@source", "@connect"]
)
# https://developer.dhl.com/api-reference/shipment-tracking#get-started-section/
@source(
name: "dhl-tracking"
http: {
baseURL: "https://api-eu.dhl.com/track"
headers: [{ name: "DHL-API-Key", value: "{$config.apiKey}" }]
}
)

type TrackingStatus @key(fields: "trackingNumber") {
trackingNumber: ID!
status: String
estimatedDeliveryDate: String
estimatedTimeOfDelivery: String
service: String
origin: Location
destination: Location
events: [TrackingEvent]
}

type Location {
countryCode: String
postalCode: String
addressLocality: String
}

type TrackingEvent {
timestamp: String
location: Location
statusCode: String
status: String
}

type Query {
tracking(trackingNumber: ID!): TrackingStatus
@connect(
source: "dhl-tracking"
http: { GET: "/shipments?trackingNumber={$args.trackingNumber}" }
selection: """
shipments->first {
trackingNumber: id
status: status.status
estimatedDeliveryDate
estimatedTimeOfDelivery
service
origin: $.origin.address {
countryCode
postalCode
addressLocality
}
destination: $.destination.address {
countryCode
postalCode
addressLocality
}
events {
timestamp
location: $.location.address {
countryCode
postalCode
addressLocality
}
statusCode
status
}
}
"""
entity: true
)
}
18 changes: 18 additions & 0 deletions connectors/dhl/router.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
supergraph:
listen: 0.0.0.0:${env.PORT:-4000}

headers:
all:
request:
- propagate:
matching: .*
telemetry:
instrumentation:
spans:
mode: spec_compliant

connectors:
subgraphs:
dhl-tracking:
$config:
apiKey: ${env.API_KEY}
6 changes: 6 additions & 0 deletions connectors/dhl/supergraph.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
federation_version: =2.10.0
subgraphs:
dhl-tracking:
routing_url: http://dhl
schema:
file: dhl-tracking.graphql
Loading