2.4.1 • Published 8 months ago

@via-profit-services/core v2.4.1

Weekly downloads
136
License
MIT
Repository
github
Last release
8 months ago

Via Profit Services / Core

via-profit-services-cover

Via Profit services / Core - GraphQL server

Documentation here

The MIT License.

Peer dependencies

  • GraphQL - The JavaScript reference implementation for GraphQL
  • Busboy - A streaming parser for HTML form data for Node. Used for the files upload

Installation

$ npm install busboy graphql @via-profit-services/core

Usage

import http from 'node:http';
import { Readable } from 'node:stream';
import { graphqlHTTPFactory } from '@via-profit-services/core';

import schema from './my-schema';

// Create the simple NodeJS HTTP server
const server = http.createServer();

// Create The graphqlHTTP listener
const graphqlHTTP = graphqlHTTPFactory({
  schema,
  debug: true, // For display geaphql extensions response
});

// Now you can use graphqlHTTP in your http request
server.on("request", async (req, res) => {
  // Allow only POST/GET request on `/graphql`
  if (
    ["POST", "GET"].includes(req.method) &&
    req.url.match(/^\/graphql(\?|$)/)
  ) {
    const { data, errors, extensions } = await graphqlHTTP(req, res);
    const response = JSON.stringify({ data, errors, extensions });
    const stream = Readable.from([response]);

    res.statusCode = 200;
    res.setHeader("content-type", "application/json");

    stream.pipe(res);
  }
});

server.listen(8080, "localhost", () => {
  console.debug("started at http://localhost:8080/graphql");
});

Documentation here

2.4.1

8 months ago

2.4.0

11 months ago

1.5.0

1 year ago

1.4.3

1 year ago

2.3.0

1 year ago

1.4.2-rc.6

2 years ago

1.4.2-rc.5

2 years ago

1.4.2-rc.4

2 years ago

2.2.0-rc.49

2 years ago

1.4.2-rc.2

2 years ago

1.4.2-rc.1

2 years ago

2.2.0-rc.47

2 years ago

2.2.0-rc.32

2 years ago

2.2.0-rc.44

2 years ago

2.2.0-rc.30

2 years ago

2.2.0-rc.31

2 years ago

2.2.0-rc.21

2 years ago

2.2.0-rc.20

2 years ago

2.2.0-rc.23

2 years ago

2.2.0-rc.22

2 years ago

2.2.0-rc.25

2 years ago

2.2.0-rc.24

2 years ago

2.2.0-rc.1

2 years ago

2.2.0-rc.18

2 years ago

2.2.0-rc.12

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

2.2.0-rc.13

2 years ago

2.2.0-rc.19

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

2.0.0-rc.11

3 years ago

2.0.0-rc.10

3 years ago

2.0.0-rc.9

3 years ago

2.0.0-rc.6

3 years ago

1.2.4

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.31.6

3 years ago

0.31.5

3 years ago

0.31.4

3 years ago

0.31.3

3 years ago

0.31.2

3 years ago

0.31.1

4 years ago

0.31.0

4 years ago

0.30.14-4

4 years ago

0.30.14-3

4 years ago

0.30.14-2

4 years ago

0.30.14-1

4 years ago

0.30.13

4 years ago

0.30.11

4 years ago

0.30.10

4 years ago

0.30.9

4 years ago

0.30.8

4 years ago