Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth9890 committed Oct 17, 2023
0 parents commit 54e59e8
Show file tree
Hide file tree
Showing 8 changed files with 4,466 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
.mesh/
13 changes: 13 additions & 0 deletions .meshrc.yml
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
39 changes: 39 additions & 0 deletions README.md
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
```

14 changes: 14 additions & 0 deletions custom-fetch.ts
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);
}
13 changes: 13 additions & 0 deletions index.ts
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();
25 changes: 25 additions & 0 deletions package.json
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"
}
}
Loading

0 comments on commit 54e59e8

Please sign in to comment.