JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 19
  • Score
    100M100P100Q21345F
  • License MIT

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

Package Exports

  • weapp-graphql-request

Readme

weapp-graphql-request (WIP)

Forked from graphql-request

Minimal GraphQL client supporting weapp environment.

Install

npm i weapp-graphql-request weapp-fetch graphql

Quick Start

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

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

  1. File upload, weapp has no Blob/File/FormData class.
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 })