Lightweight GraphQL server & client for Electron apps. (WIP)
MIT License
Lightweight GraphQL server & client for Electron apps.
This project is WORK IN PROGRESS, do NOT try to use it :trollface:
npm i electron-graphql
// `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()
// `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()
(TODO).