-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 54e59e8
Showing
8 changed files
with
4,466 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
.mesh/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
sources: | ||
- name: MyGraphQLApi | ||
handler: | ||
graphql: | ||
endpoint: https://develop.protocol.mygateway.xyz/v1/graphql | ||
method: "POST" | ||
useGETForQueries: false | ||
|
||
customFetch: ./custom-fetch.ts | ||
|
||
sdk: | ||
generateOperations: | ||
selectionSetDepth: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
![](https://raw.githubusercontent.com/Gateway-DAO/ui/main/apps/website/public/social.png) | ||
|
||
# ⚙️ Gateway Javascript SDK | ||
|
||
POC made using graphql mesh | ||
|
||
## 🔧 Installation | ||
|
||
1. Clone this repo | ||
|
||
```sh | ||
git clone https://github.com/Gateway-DAO/javascript-sdk | ||
``` | ||
|
||
2. Install dependencies using pnpm | ||
|
||
```sh | ||
pnpm i | ||
``` | ||
|
||
3. Create the sdk using graphql mesh(it should give .mesh folder with sdk in it) | ||
|
||
```sh | ||
pnpm mesh build | ||
``` | ||
|
||
4. Replace the bearer token with yours in custom-fetch file | ||
|
||
```sh | ||
init.headers["Authorization"] = | ||
"Bearer your-token"; | ||
``` | ||
|
||
5. Run dev command to test sdk | ||
|
||
```sh | ||
pnpm dev | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { MeshContext } from "@graphql-mesh/runtime"; | ||
import { fetch } from "@whatwg-node/fetch"; | ||
|
||
export default function patchedFetch( | ||
url: string, | ||
init: any, | ||
context: MeshContext | ||
) { | ||
console.debug(url, init.headers); | ||
init.headers["Authorization"] = | ||
"Bearer your-token"; | ||
|
||
return fetch(url, init); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { getMeshSDK } from "./.mesh/index"; | ||
|
||
async function test() { | ||
const sdk = getMeshSDK(); | ||
|
||
try { | ||
const { me } = await sdk.me_query(); | ||
console.log(me.createdAt); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
test(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "javascript-sdk", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"dev": "ts-node ./index.ts" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@graphql-mesh/cli": "^0.87.14", | ||
"@graphql-mesh/graphql": "^0.95.7", | ||
"@graphql-mesh/runtime": "^0.96.11", | ||
"@types/node": "^20.8.4", | ||
"@whatwg-node/fetch": "^0.9.13", | ||
"graphql": "^16.8.1" | ||
}, | ||
"devDependencies": { | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
Oops, something went wrong.