Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #20 from textileio/carson/query-api
Browse files Browse the repository at this point in the history
[feat]: support graphql query api
  • Loading branch information
carsonfarmer authored Nov 4, 2021
2 parents e33f3cd + a22de91 commit 07eb5b2
Show file tree
Hide file tree
Showing 14 changed files with 10,893 additions and 913 deletions.
7 changes: 7 additions & 0 deletions .changeset/wise-mugs-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@textile/core-storage": major
"@textile/eth-storage": major
"@textile/near-storage": major
---

Support query by cid, fetch by cid, and new response types (breaking change)
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ out/
dist/
coverage/
docs/
packages/core/src/client.ts
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
publish: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
9,643 changes: 8,849 additions & 794 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
"html"
]
}
}
}
10 changes: 10 additions & 0 deletions packages/core/graphql/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
schema: https://broker.staging.textile.dev/graphql
documents: ./graphql/query.graphql
generates:
src/client.ts:
plugins:
- typescript
- typescript-operations
- typescript-graphql-request
config:
rawRequest: true
43 changes: 43 additions & 0 deletions packages/core/graphql/query.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
query statusByCid($dataCid: String!) {
requests: allStorageRequests(condition: { dataCid: $dataCid }) {
nodes {
status
id
cid: dataCid
batch: batchByStoragePayloadId {
payload: storagePayloadByStoragePayloadId {
deals: dealsByStoragePayloadId {
nodes {
deal_id: dealId
miner: storageProviderId
deal_expiration: dealExpiration
deal_status: marketDealStatus
}
}
}
}
}
}
}

query statusById($id: String!) {
requests: allStorageRequests(condition: { id: $id }) {
nodes {
status
id
cid: dataCid
batch: batchByStoragePayloadId {
payload: storagePayloadByStoragePayloadId {
deals: dealsByStoragePayloadId {
nodes {
deal_id: dealId
miner: storageProviderId
deal_expiration: dealExpiration
deal_status: marketDealStatus
}
}
}
}
}
}
}
15 changes: 12 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"scripts": {
"build": "npm run build:cjs && npm run build:esm",
"build:cjs": "tsc -b",
"build:esm": "ttsc -b tsconfig.esm.json"
"build:esm": "ttsc -b tsconfig.esm.json",
"build:client": "graphql-codegen -c graphql/codegen.yml"
},
"exports": {
".": {
Expand All @@ -24,6 +25,14 @@
"src/**/*.ts"
],
"dependencies": {
"@stablelib/base64": "^1.0.1"
"@stablelib/base64": "^1.0.1",
"cross-fetch": "^3.1.4",
"graphql": "^15.7.2",
"graphql-request": "^3.6.1"
},
"devDependencies": {
"@graphql-codegen/cli": "^2.2.2",
"@graphql-codegen/typescript-graphql-request": "^4.2.0",
"@graphql-codegen/typescript-operations": "^2.2.0"
}
}
}
Loading

0 comments on commit 07eb5b2

Please sign in to comment.