# weapp-graphql-request

> This is a util fork form graphql-request and only worked in weapp environment

Latest version **0.2.0** (published 2023-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install weapp-graphql-request
pnpm add weapp-graphql-request
yarn add weapp-graphql-request
bun add weapp-graphql-request
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2023-07-03 |
| First published | 2023-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 113.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | SonOfMagic |
| Maintainers | icebreaker |
| Keywords | weapp, graphql, request, fetch, graphql-client |

## Links

- npm: https://www.npmjs.com/package/weapp-graphql-request
- Repository: https://github.com/sonofmagic/weapp-graphql-request
- Issues: https://github.com/sonofmagic/weapp-graphql-request/issues
- npm.io page: https://npm.io/package/weapp-graphql-request

## Dependencies (1)

- [@graphql-typed-document-node/core](https://npm.io/package/@graphql-typed-document-node/core.md) ^3.2.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2023-07-03
- 0.2.0-alpha.0 (alpha) — 2023-05-03
- 0.1.4 — 2023-04-18
- 0.1.3 — 2023-03-10
- 0.1.2 — 2023-03-09
- 0.1.1 — 2023-03-07
- 0.1.0 — 2023-03-07
- 0.0.6 — 2023-03-06
- 0.0.5 — 2023-03-06
- 0.0.4 — 2023-03-06
- 0.0.3 — 2023-03-06
- 0.0.2 — 2023-03-06
- 0.0.1 — 2023-03-06

## README

# weapp-graphql-request (WIP)

> Forked from [graphql-request](https://www.npmjs.com/package/graphql-request)

Minimal GraphQL client supporting weapp environment.

## Install

```sh
npm i weapp-graphql-request weapp-fetch graphql
```

## Quick Start

```js
import { GraphQLClient } from 'weapp-graphql-request'
import { createFetch } from 'weapp-fetch'
// const weappFetch = createFetch(wx.request)
// const uniFetch = createFetch(uni.request)
// const taroFetch = createFetch(taro.request)
// etc..
const graphQLClient = new GraphQLClient('http://localhost:3000', {
  fetch: weappFetch,
})

graphQLClient.request(query, variables).then((data) => console.log(data))
```

you should install `weapp-fetch` instead of other `fetch` implement because only this lib can run in weapp environment.

## Environment support

| weapp | alipay | swan | tt  | qq  | jd  | quickapp |
| ----- | ------ | ---- | --- | --- | --- | -------- |
| √     | ?      | ?    | ?   | ?   | ?   | ?        |

## Framework support

| uni-app | taro | others |
| ------- | ---- | ------ |
| √       | √    | ?      |

## Usages

Refers to [graphql-request](https://www.npmjs.com/package/graphql-request)

You can read it's doc for usage, but there are some points not support.

<!-- 1. `GraphQLWebSocketClient`, cause weapp have another websocket implement which different from  `the standard`。 -->

1. `File upload`, weapp has no `Blob`/`File`/`FormData` class.

```js
import { GraphQLWebSocketClient } from 'weapp-graphql-request'
const task = wx.connectSocket({
  url: 'wss://example.qq.com',
  header: {
    'content-type': 'application/json',
  },
  protocols: ['protocol1'],
})

const wsClient = new GraphQLWebSocketClient(task, { onInit, onAcknowledged, onPing, onPong })
```

---
_Source: https://npm.io/package/weapp-graphql-request · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
