Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
Convert CommonJS module syntax to ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrearden authored and IvanGoncharov committed Jun 9, 2020
1 parent 3ede973 commit 0f74f05
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 179 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Just mount `express-graphql` as a route handler:

```js
const express = require('express');
const graphqlHTTP = require('express-graphql');
const { graphqlHTTP } = require('express-graphql');

const app = express();

Expand All @@ -49,7 +49,7 @@ Use `.get` or `.post` (or both) rather than `.use` to configure your route handl

```js
const restify = require('restify');
const graphqlHTTP = require('express-graphql');
const { graphqlHTTP } = require('express-graphql');

const app = restify.createServer();

Expand Down Expand Up @@ -196,7 +196,7 @@ This example uses [`express-session`][] to provide GraphQL with the currently lo

```js
const session = require('express-session');
const graphqlHTTP = require('express-graphql');
const { graphqlHTTP } = require('express-graphql');

const app = express();

Expand Down Expand Up @@ -243,7 +243,7 @@ This example illustrates adding the amount of time consumed by running the
provided query, which could perhaps be used by your development tools.

```js
const graphqlHTTP = require('express-graphql');
const { graphqlHTTP } = require('express-graphql');

const app = express();

Expand Down Expand Up @@ -321,9 +321,9 @@ running a GraphQL request. This function is used internally to handle the
incoming request, you may use it directly for building other similar services.

```js
const graphqlHTTP = require('express-graphql');
const { getGraphQLParams } = require('express-graphql');

graphqlHTTP.getGraphQLParams(request).then((params) => {
getGraphQLParams(request).then((params) => {
// do something...
});
```
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
parse,
} from 'graphql';

import graphqlHTTP from '../index';
import { graphqlHTTP } from '../index';

const QueryRootType = new GraphQLObjectType({
name: 'QueryRoot',
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/usage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { expect } from 'chai';
import { describe, it } from 'mocha';
import { GraphQLSchema } from 'graphql';

import graphqlHTTP from '../index';
import { graphqlHTTP } from '../index';

describe('Useful errors when incorrectly used', () => {
it('requires an option factory function', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ type Middleware = (request: $Request, response: $Response) => Promise<void>;
* Middleware for express; takes an options object or function as input to
* configure behavior, and returns an express middleware.
*/
module.exports = graphqlHTTP;
function graphqlHTTP(options: Options): Middleware {
export function graphqlHTTP(options: Options): Middleware {
if (!options) {
throw new Error('GraphQL middleware requires options.');
}
Expand Down Expand Up @@ -456,8 +455,9 @@ export type GraphQLParams = {|
* Provided a "Request" provided by express or connect (typically a node style
* HTTPClientRequest), Promise the GraphQL request parameters.
*/
module.exports.getGraphQLParams = getGraphQLParams;
async function getGraphQLParams(request: $Request): Promise<GraphQLParams> {
export async function getGraphQLParams(
request: $Request,
): Promise<GraphQLParams> {
const { url = '' } = request;
const urlData = new URLSearchParams(url.split('?')[1]);
const bodyData = await parseBody(request);
Expand Down
Loading

0 comments on commit 0f74f05

Please sign in to comment.