JSPM

  • Created
  • Published
  • Downloads 190
  • Score
    100M100P100Q62925F
  • License MIT

the grafoo client preact bindings

Package Exports

  • @grafoo/preact

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@grafoo/preact) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@grafoo/preact

Grafoo Preact Bindings

build coverage npm downloads size code style: prettier mantained with: lerna

Install

$ npm i @grafoo/{core,react} && npm i -D @grafoo/babel-plugin

API

For documentation please refer to @grafoo/react's page since both modules share the same API.

Example

index.js

import { h, render } from "preact";
import createClient from "@grafoo/core";
import { Provider } from "@grafoo/preact";

import Posts from "./Posts";

const client = createClient("http://some.graphql/api/");

render(
  <Provider client={client}>
    <Posts />
  </Provider>,
  document.getElementById("mnt")
);

Posts.js

import { h } from "preact";
import gql from "@grafoo/core/tag";
import { Consumer } from "@grafoo/preact";

const ALL_POSTS = gql`
  query getPosts($orderBy: PostOrderBy) {
    allPosts(orderBy: $orderBy) {
      title
      content
      createdAt
      updatedAt
    }
  }
`;

export default function Posts() {
  return (
    <Consumer query={ALL_POSTS} variables={{ orderBy: "createdAt_DESC" }}>
      {({ client, load, loading, loaded, errors, allPosts }) => (
        <h1>
          <marquee>👆 do whatever you want with the variables above 👆</marquee>
        </h1>
      )}
    </Consumer>
  );
}

LICENSE

MIT