Skip to content

Commit

Permalink
run lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
evans committed Jul 13, 2018
1 parent c2ebc02 commit 8d42045
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 45 deletions.
82 changes: 41 additions & 41 deletions packages/apollo-server-hapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,61 +56,61 @@ StartServer();
```

## Hapi 16

Imports must be monkey patched for Hapi 16 support (mainly attributes).

```js

import { graphqlHapi, graphiqlHapi } from 'apollo-server-hapi';

// add attributes for hapi 16
graphqlHapi.attributes = {
name: graphqlHapi.name
name: graphqlHapi.name,
};

// if you happen to use graphiql then add attributes for hapi 16
graphiqlHapi.attributes = {
name: graphiqlHapi.name
name: graphiqlHapi.name,
};

async function StartServer() {
const server = new Hapi.server({
host: HOST,
port: PORT,
});

await server.register({
plugin: graphqlHapi,
options: {
path: '/graphql',
graphqlOptions: {
schema: myGraphQLSchema,
},
route: {
cors: true,
},
},
});

await server.register({
plugin: graphiqlHapi,
options: {
path: '/graphiql',
route: {
cors: true,
},
graphiqlOptions: {
endpointURL: 'graphql'
}
},
});

try {
await server.start();
} catch (err) {
console.log(`Error while starting server: ${err.message}`);
}

console.log(`Server running at: ${server.info.uri}`);
const server = new Hapi.server({
host: HOST,
port: PORT,
});

await server.register({
plugin: graphqlHapi,
options: {
path: '/graphql',
graphqlOptions: {
schema: myGraphQLSchema,
},
route: {
cors: true,
},
},
});

await server.register({
plugin: graphiqlHapi,
options: {
path: '/graphiql',
route: {
cors: true,
},
graphiqlOptions: {
endpointURL: 'graphql',
},
},
});

try {
await server.start();
} catch (err) {
console.log(`Error while starting server: ${err.message}`);
}

console.log(`Server running at: ${server.info.uri}`);
}

StartServer();
Expand Down
10 changes: 6 additions & 4 deletions packages/apollo-server-hapi/src/hapiApollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from 'apollo-server-core';

export interface IRegister {
(server: Server, options: any, next?: Function): void;
(server: Server, options: any, next?: Function): void;
}

export interface IPlugin {
Expand All @@ -17,7 +17,6 @@ export interface IPlugin {
register: IRegister;
}


export interface HapiOptionsFunction {
(req?: Request): GraphQLOptions | Promise<GraphQLOptions>;
}
Expand Down Expand Up @@ -95,7 +94,11 @@ export interface HapiGraphiQLPluginOptions {

const graphiqlHapi: IPlugin = {
name: 'graphiql',
register: (server: Server, options: HapiGraphiQLPluginOptions, next?: Function) => {
register: (
server: Server,
options: HapiGraphiQLPluginOptions,
next?: Function,
) => {
if (!options || !options.graphiqlOptions) {
throw new Error('Apollo Server GraphiQL requires options.');
}
Expand Down Expand Up @@ -124,4 +127,3 @@ const graphiqlHapi: IPlugin = {
};

export { graphqlHapi, graphiqlHapi };

0 comments on commit 8d42045

Please sign in to comment.