Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apollo-server-hapi

Package Overview
Dependencies
Maintainers
5
Versions
305
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-server-hapi - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

12

package.json
{
"name": "apollo-server-hapi",
"version": "1.3.2",
"version": "1.3.3",
"description": "Production-ready Node.js GraphQL server for Hapi",

@@ -28,10 +28,10 @@ "main": "dist/index.js",

"dependencies": {
"apollo-server-core": "^1.3.2",
"apollo-server-module-graphiql": "^1.3.0",
"apollo-server-core": "^1.3.3",
"apollo-server-module-graphiql": "^1.3.3",
"boom": "^7.1.0"
},
"devDependencies": {
"@types/graphql": "0.11.7",
"apollo-server-integration-testsuite": "^1.3.2",
"hapi": "17.1.1"
"@types/graphql": "0.12.6",
"apollo-server-integration-testsuite": "^1.3.3",
"hapi": "17.2.3"
},

@@ -38,0 +38,0 @@ "typings": "dist/index.d.ts",

@@ -16,3 +16,3 @@ ---

With the Hapi plugins `graphqlHapi` and `graphiqlHapi` you can pass a route object that includes options to be applied to the route. The example below enables CORS on the `/graphql` route.
With the Hapi plugins `graphqlHapi` and `graphiqlHapi` you can pass a route object that includes options to be applied to the route. The example below enables CORS on the `/graphql` route.

@@ -29,27 +29,27 @@ The code below requires Hapi 17 or higher.

async function StartServer() {
const server = new Hapi.server({
host: HOST,
port: PORT,
});
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: graphqlHapi,
options: {
path: '/graphql',
graphqlOptions: {
schema: myGraphQLSchema,
},
route: {
cors: true,
},
},
});
try {
await server.start();
} catch (err) {
console.log(`Error while starting server: ${err.message}`);
}
try {
await server.start();
} catch (err) {
console.log(`Error while starting server: ${err.message}`);
}
console.log(`Server running at: ${server.info.uri}`);
console.log(`Server running at: ${server.info.uri}`);
}

@@ -68,3 +68,2 @@

Anyone is welcome to contribute to Apollo Server, just read [CONTRIBUTING.md](https://github.com/apollographql/apollo-server/blob/master/CONTRIBUTING.md), take a look at the [roadmap](https://github.com/apollographql/apollo-server/blob/master/ROADMAP.md) and make your first PR!

@@ -5,24 +5,29 @@ import * as hapi from 'hapi';

import testSuite, { schema as Schema, CreateAppOptions } from 'apollo-server-integration-testsuite';
import testSuite, {
schema as Schema,
CreateAppOptions,
} from 'apollo-server-integration-testsuite';
async function createApp(options: CreateAppOptions) {
const server = new hapi.Server({
host: 'localhost',
port: 8000,
host: 'localhost',
port: 8000,
});
await server.register({
plugin: graphqlHapi,
options: {
graphqlOptions: (options && options.graphqlOptions) || { schema: Schema },
path: '/graphql',
},
plugin: graphqlHapi,
options: {
graphqlOptions: (options && options.graphqlOptions) || { schema: Schema },
path: '/graphql',
},
});
await server.register({
plugin: graphiqlHapi,
options: {
path: '/graphiql',
graphiqlOptions: (options && options.graphiqlOptions) || { endpointURL: '/graphql' },
plugin: graphiqlHapi,
options: {
path: '/graphiql',
graphiqlOptions: (options && options.graphiqlOptions) || {
endpointURL: '/graphql',
},
},
});

@@ -39,3 +44,3 @@

}
await new Promise((resolve) => app.close(resolve));
await new Promise(resolve => app.close(resolve));
}

@@ -42,0 +47,0 @@

import * as Boom from 'boom';
import { Server, Response, Request, ReplyNoContinue } from 'hapi';
import * as GraphiQL from 'apollo-server-module-graphiql';
import { GraphQLOptions, runHttpQuery, HttpQueryError } from 'apollo-server-core';
import {
GraphQLOptions,
runHttpQuery,
HttpQueryError,
} from 'apollo-server-core';
export interface IRegister {
(server: Server, options: any): void;
(server: Server, options: any): void;
}

@@ -51,7 +55,7 @@

} catch (error) {
if ( 'HttpQueryError' !== error.name ) {
if ('HttpQueryError' !== error.name) {
throw Boom.boomify(error);
}
if ( true === error.isGraphQLError ) {
if (true === error.isGraphQLError) {
const response = h.response(error.message);

@@ -63,5 +67,5 @@ response.code(error.statusCode);

const err = new Boom(error.message, {statusCode: error.statusCode});
if ( error.headers ) {
Object.keys(error.headers).forEach((header) => {
const err = new Boom(error.message, { statusCode: error.statusCode });
if (error.headers) {
Object.keys(error.headers).forEach(header => {
err.output.headers[header] = error.headers[header];

@@ -101,3 +105,7 @@ });

handler: async (request, h) => {
const graphiqlString = await GraphiQL.resolveGraphiQLString(request.query, options.graphiqlOptions, request);
const graphiqlString = await GraphiQL.resolveGraphiQLString(
request.query,
options.graphiqlOptions,
request,
);

@@ -104,0 +112,0 @@ const response = h.response(graphiqlString);

@@ -1,6 +0,9 @@

export { IRegister,
HapiOptionsFunction,
HapiPluginOptions,
HapiGraphiQLOptionsFunction,
HapiGraphiQLPluginOptions,
graphqlHapi, graphiqlHapi } from './hapiApollo';
export {
IRegister,
HapiOptionsFunction,
HapiPluginOptions,
HapiGraphiQLOptionsFunction,
HapiGraphiQLPluginOptions,
graphqlHapi,
graphiqlHapi,
} from './hapiApollo';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc