Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

altangent/regraph-request

Repository files navigation

regraph-request

Simple React GraphQL requests

NPM

Install

npm install --save regraph-request

Usage

import React from 'react';
import PropTypes from 'prop-types';
import { Query } from 'regraph-request';

const QUERY = `
  query Test(
    $inputName: String
  ) {
    hello(name: $inputName)
  }
`;

export const HelloComponent = ({ data }) => {
  if (!data.hello) return <div />;
  return <div>{data.hello}</div>;
};

HelloComponent.propTypes = {
  username: PropTypes.string,
};

export const Hello = Query(HelloComponent, QUERY, props => ({
  inputName: props.username,
}));

export const App = () => {
  return (
    <RegraphRequest value="https://example.com/graphql">
      <Hello />
    </RegraphRequest>
  );
};

License

MIT © Altangent

Releases

No releases published

Packages

No packages published