2.7.0 • Published 7 months ago

@via-profit-services/core v2.7.0

Weekly downloads
136
License
MIT
Repository
github
Last release
7 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.7.0

7 months ago

2.6.0

9 months ago

2.5.0

11 months ago

2.4.1

2 years ago

2.4.0

2 years ago

1.5.0

2 years ago

1.4.3

2 years ago

2.3.0

3 years ago

1.4.2-rc.6

3 years ago

1.4.2-rc.5

3 years ago

1.4.2-rc.4

3 years ago

2.2.0-rc.49

3 years ago

1.4.2-rc.2

3 years ago

1.4.2-rc.1

3 years ago

2.2.0-rc.47

3 years ago

2.2.0-rc.32

3 years ago

2.2.0-rc.44

3 years ago

2.2.0-rc.30

3 years ago

2.2.0-rc.31

3 years ago

2.2.0-rc.21

3 years ago

2.2.0-rc.20

4 years ago

2.2.0-rc.23

3 years ago

2.2.0-rc.22

3 years ago

2.2.0-rc.25

3 years ago

2.2.0-rc.24

3 years ago

2.2.0-rc.1

4 years ago

2.2.0-rc.18

4 years ago

2.2.0-rc.12

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

2.2.0-rc.13

4 years ago

2.2.0-rc.19

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

2.0.0-rc.11

4 years ago

2.0.0-rc.10

4 years ago

2.0.0-rc.9

4 years ago

2.0.0-rc.6

4 years ago

1.2.4

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.31.6

5 years ago

0.31.5

5 years ago

0.31.4

5 years ago

0.31.3

5 years ago

0.31.2

5 years ago

0.31.1

5 years ago

0.31.0

5 years ago

0.30.14-4

5 years ago

0.30.14-3

5 years ago

0.30.14-2

5 years ago

0.30.14-1

5 years ago

0.30.13

5 years ago

0.30.11

5 years ago

0.30.10

5 years ago

0.30.9

5 years ago

0.30.8

5 years ago