draqula

? GraphQL client for minimalistic React apps

  • 所有者: vadimdemedes/draqula
  • 平台:
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Draqula is a GraphQL client for React apps that don't need everything.
Instead of offering tons of features like extensive caching mechanism, local state management, subscriptions and so on, Draqula focuses on executing the basics well - queries and mutations.

If you want to take a quick look, keep scrolling this readme.
Otherwise, check out the documentation at https://draqulajs.com.

Install

$ npm install draqula graphql graphql-tag

Features

  • Simple API and codebase
  • Basic cache implementation with aggressive invalidation and refetching
  • Automatic retries of network/timeout errors and GraphQL queries
  • Straightforward way to hook into requests without a need for middleware
  • Refetches queries when window gets focused

Usage

import React from 'react';
import {render} from 'react-dom';
import {Draqula, DraqulaProvider, useQuery} from 'draqula';
import gql from 'graphql-tag';

const TODOS_QUERY = gql`
	query {
		todos {
			id
			title
		}
	}
`;

const Todos = () => {
	const {data, isLoading, error} = useQuery(TODOS_QUERY);

	return (
		<div>
			{isLoading && <span>Loading…</span>}
			{error && <span>Error: {error.message}</span>}
			{data && (
				<ul>
					{data.todos.map(todo => (
						<li key={todo.id}>{todo.title}</li>
					))}
				</ul>
			)}
		</div>
	);
};

const client = new Draqula('https://my-graphql-api.com/graphql');

render(
	<DraqulaProvider client={client}>
		<Todos />
	</DraqulaProvider>,
	document.body
);

Documentation

Docs can be found at https://draqulajs.com

主要指標

概覽
名稱與所有者vadimdemedes/draqula
主編程語言JavaScript
編程語言TypeScript (語言數: 2)
平台
許可證
所有者活动
創建於2019-08-25 01:39:40
推送於2020-04-04 06:58:44
最后一次提交2020-04-04 09:57:59
發布數15
最新版本名稱v0.5.4 (發布於 2020-04-04 09:58:00)
第一版名稱v0.1.0 (發布於 2019-09-02 22:40:08)
用户参与
星數768
關注者數10
派生數13
提交數73
已啟用問題?
問題數19
打開的問題數6
拉請求數6
打開的拉請求數0
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?