# @cfpreview/pages-plugins-graphql

> # GraphQL

Latest version **0.1.1** (published 2022-02-11) · 0 weekly downloads

## Install

```sh
npm install @cfpreview/pages-plugins-graphql
pnpm add @cfpreview/pages-plugins-graphql
yarn add @cfpreview/pages-plugins-graphql
bun add @cfpreview/pages-plugins-graphql
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2022-02-11 |
| First published | 2022-01-30 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | gregbrimble, 1000hz, geelen |

## Links

- npm: https://www.npmjs.com/package/@cfpreview/pages-plugins-graphql
- npm.io page: https://npm.io/package/@cfpreview/pages-plugins-graphql

## Recent versions

- 0.1.1 (latest) — 2022-02-11
- 0.1.0 — 2022-01-31
- 0.0.4 — 2022-01-31
- 0.0.3 — 2022-01-30
- 0.0.1 — 2022-01-30

## README

## Pages Plugins

# GraphQL

This GraphQL plugin creates a GraphQL server which can respond to `application/json` and `application/graphql` `POST` requests. It responds with [the GraphQL Playground](https://github.com/graphql/graphql-playground) for `GET` requests.

## Installation

```sh
npm install --save @cfpreview/pages-plugins-graphql
```

## Usage

```typescript
// ./functions/graphql.ts

import graphQLPlugin from "@cfpreview/pages-plugins-graphql";
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";

const schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: "RootQueryType",
    fields: {
      hello: {
        type: GraphQLString,
        resolve() {
          return "Hello, world!";
        },
      },
    },
  }),
});

export const onRequest: PagesFunction = graphQLPlugin({
  schema,
});
```

This plugin only exposes a single route, so wherever it is mounted is wherever it will be available. In the above example, because it is mounted in `./functions/graphql.ts` the server will be available on `/graphql` of the app.

---
_Source: https://npm.io/package/@cfpreview/pages-plugins-graphql · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
