graphql-io
v1.8.4
Published
GraphQL Network Communication Framework (Meta)
Downloads
19
Maintainers
Readme
GraphQL-IO | GraphQL-IO-Client | GraphQL-IO-Server
GraphQL-IO
GraphQL Network Communication Framework
ATTENTION: This is just a meta-package for GraphQL-IO. Please check out GraphQL-IO-Client and GraphQL-IO-Server for the real client and server implementation packages!
About
This is a GraphQL-based network communication framework for JavaScript clients, running under either Node.js or in the Browser, and JavaScript servers, running under Node.js. The client-side is provided by the module GraphQL-IO-Client, the server-side is provided by the module GraphQL-IO-Server. This is just a meta-package which bundles the server and client packages for being able to conveniently reference both the server and the client in their latest versions through a single package. Feel free to just use (particular versions of) the individual packages directly.
On the client-side, it is based on the GraphQL engine GraphQL.js, the GraphQL client library Apollo Client, its WebSocket network interface Apollo Client WS and the HTTP client library Axios.
On the server-side, it is based on the GraphQL engine GraphQL.js, the GraphQL schema execution library GraphQL-Tools, the GraphQL type definition library GraphQL-Tools-Types, the GraphQL subscription management library GraphQL-Tools-Subscribe, the network communication framework HAPI, the WebSocket integration plugin HAPI-Plugin-WebSocket and the GraphiQL integration plugin HAPI-Plugin-GraphiQL.
Installation
# all-in-one
$ npm install graphql-io
# client-side only
$ npm install graphql-io-client
# server-side only
$ npm install graphql-io-server
Usage
/* all-in-one */
import { Client } from "graphql-io"
import { Server } from "graphql-io"
/* client-side only */
import { Client } from "graphql-io-client"
/* server-side only */
import { Server } from "graphql-io-server"
For particular usage details, please see the GraphQL-IO-Client package and its GraphQL-IO-Client API and the GraphQL-IO-Server package and its GraphQL-IO-Server API.
Sample
/* Hello World Server */
const { Server } = require("graphql-io-server")
const server = new Server({ url: "http://127.0.0.1:12345/api" })
server.at("graphql-resolver", () => ({
Root: { hello: [ "hello: String", () => "world" ] }
}))
await server.start()
/* Hello World Client */
const { Client } = require("graphql-io-client")
const client = new Client({ url: "http://127.0.0.1:12345/api" })
await client.connect()
let result = await client.query("{ hello }")
await client.disconnect()
console.log(result.data)
For more elaborate samples, check out the Samples folder. These samples show a minimum Hello World, subscriptions over separate client connections, real-time performance of server, usage from within Node.js and the Browser, etc.
License
Copyright (c) 2016-2019 Ralf S. Engelschall (http://engelschall.com/)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.