Caching request service to strava. Entities cached/stored in mongodb and you can get them with graphQL
sequenceDiagram
participant GraphQL
participant MongoDB
participant Strava API
GraphQL->>MongoDB: Mutation - addToken // store athlete refresh_token
GraphQL->>MongoDB: Mutation - reloadAthleteActivities (:athleteIds)
MongoDB->>Strava API: request GET activities with refresh_token
Strava API->>MongoDB: insert activities into mongodb
MongoDB->>GraphQL: Subscription - activities // send to subscribers
GraphQL->>MongoDB: Query - activity | activities (:athleteIds)
MongoDB->>GraphQL: get activities with specified fields
STRAVA_CLIENT
- strava client idSTRAVA_SECRET
- strava secret idMONGO_CONNECTION
(localhost) - mongo connection stringACTIVITY_BATCH_SIZE
(50) - max batch size, after which data is sent to subscribersACTIVITY_BATCH_TIME
(45s) - time after which data is sent to subscribersSLUG
(integration-strava) - prefix for url pathPORT
(8080) - server port
- GET
{SLUG}/healthz
- health check - GET
{SLUG}/api/quota
- actual strava's request quota - GET
{SLUG}/api/subscription
- used for registration strava webhook - POST
{SLUG}/api/subscription
- strava sends changes here - GET
{SLUG}/graphql/
- graphQL playgroud - More about graphQL queries / mutations / subscriptions
- set environments
STRAVA_CLIENT
,STRAVA_SECRET
,MONGO_CONNECTION
- localhost mongo
docker run -d --restart=always --name mongodb -p 27017:27017 mongo
- local service
docker run -d --restart=always --name strava-graphql --network host -e STRAVA_CLIENT=<client_id> -e STRAVA_SECRET=<secret_id> sealway/strava
- strava api credentials here
- graphql queries docs
- timestamp converter
- Generate strava client
git clone https://github.com/swagger-api/swagger-codegen.git
cd ./swagger-codegen
- for Windows in
./run-in-docker.sh
addMSYS_NO_PATHCONV=1
beforedocker run ...
- for Windows in
./run-in-docker.sh generate --input-spec https://developers.strava.com/swagger/swagger.json --lang go --output /gen/go/
./run-in-docker.sh generate --input-spec https://developers.strava.com/swagger/swagger.json --lang openapi --output /gen/openapi/
- Replace
package swagger
topackage strava
(json:"([^,]+),)
tobson:"$2" $1
- Generate grahpql with strava models
cd ./graph
go run github.com/99designs/gqlgen generate
- Replace
model.
tostrava.
without mutations ingraph/generated/generated.go
and rollbackschema.resolvers.go
strava.NewAthleteToken
=>model.NewAthleteToken
strava.AthleteToken
=>model.AthleteToken
- change go version in
go.mod
go get -u all
- graphql generate
[Type!]!
or[Type!]
here