0.2.1 • Published 6 years ago

electron-graphql v0.2.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

electron-graphql

Lightweight GraphQL server & client for Electron apps.

This project is WORK IN PROGRESS, do NOT try to use it :trollface:

Installation

npm i electron-graphql

Usage

main progress

// `executor` only works in main progress
const { createGraphQLExecutor } = require("electron-graphql")

// create GraphQL executor
const gqlExecutor = createGraphQLExecutor({
  // electron IPC channel (base name)
  channel,
  schema,
  rootValue,
  contextValue
})

// init GraphQL executor
gqlExecutor.init()

// dispose GraphQL executor
gqlExecutor.dispose()

renderer process

// `fetcher` only works in renderer process
import { createGraphQLFetcher } from "electron-graphql"

// create GraphQL fetcher
const gqlFetcher = createGraphQLFetcher({ channel, timeout })

// init GraphQL fetcher
gqlFetcher.init()

// use GraphQL fetch
gqlFetcher.fetch({ query, variables, operationName })
  .then(result => {
    const { data, errors, extensions } = result
    // GraphQL errors and extensions are optional
  })
  .catch(error => {
    //respond to a connect error
  })

// dispose GraphQL fetcher
gqlFetcher.dispose()

API

(TODO).