Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
acao committed Jul 6, 2023
1 parent d869a6d commit 3da4419
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,11 @@ export default {
};
```

##### With [`Netlify functions`](https://docs.netlify.com/functions/overview/)
##### With [`Netlify Functions`](https://docs.netlify.com/functions/overview/)

in `<functionsDirectory>/graphql.mjs`
```js
import { createHandler } from 'graphql-http/lib/use/netlify'; // npm install graphql-http
import { createHandler } from 'graphql-http/lib/use/@netlify/functions'; // npm install @netlify/functions
import { schema } from './previous-step';

// Create the GraphQL over HTTP native fetch handler
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ graphql-http
- [client](modules/client.md)
- [common](modules/common.md)
- [handler](modules/handler.md)
- [use/@netlify/functions](modules/use__netlify_functions.md)
- [use/express](modules/use_express.md)
- [use/fastify](modules/use_fastify.md)
- [use/fetch](modules/use_fetch.md)
Expand Down
51 changes: 51 additions & 0 deletions docs/modules/use__netlify_functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[graphql-http](../README.md) / use/@netlify/functions

# Module: use/@netlify/functions

## Table of contents

### Type Aliases

- [HandlerOptions](use__netlify_functions.md#handleroptions)

### Functions

- [createHandler](use__netlify_functions.md#createhandler)

## Server/netlify

### HandlerOptions

Ƭ **HandlerOptions**<`Context`\>: [`HandlerOptions`](../interfaces/handler.HandlerOptions.md)<`HandlerEvent`, `HandlerContext`, `Context`\>

Handler options when using the netlify adapter

#### Type parameters

| Name | Type |
| :------ | :------ |
| `Context` | extends [`OperationContext`](handler.md#operationcontext) = `undefined` |

___

### createHandler

**createHandler**<`Context`\>(`options`): `Handler`

Create a GraphQL over HTTP spec compliant request handler for netlify functions

#### Type parameters

| Name | Type |
| :------ | :------ |
| `Context` | extends [`OperationContext`](handler.md#operationcontext) = `undefined` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `options` | [`HandlerOptions`](use__netlify_functions.md#handleroptions)<`Context`\> |

#### Returns

`Handler`
7 changes: 7 additions & 0 deletions functions/graphql.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { GraphQLSchema } from 'graphql';
import { createHandler } from 'graphql-http/lib/use/@netlify/functions'; // npm install @netlify/functions

const schema = new GraphQLSchema()

// Create the GraphQL over HTTP native fetch handler
export const handler = createHandler({ schema });
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
"require": "./lib/use/fastify.js",
"import": "./lib/use/fastify.mjs"
},
"./lib/use/@netlify/functions": {
"types": "./lib/use/@netlify/functions.d.ts",
"require": "./lib/use/@netlify/functions.js",
"import": "./lib/use/@netlify/functions.mjs"
},
"./lib/use/koa": {
"types": "./lib/use/koa.d.ts",
"require": "./lib/use/koa.js",
Expand Down
2 changes: 1 addition & 1 deletion src/use/netlify.ts → src/use/@netlify/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
createHandler as createRawHandler,
HandlerOptions as RawHandlerOptions,
OperationContext,
} from '../handler';
} from '../../handler';

import type { Handler, HandlerEvent, HandlerContext } from '@netlify/functions';

Expand Down

0 comments on commit 3da4419

Please sign in to comment.