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

apollo-server-micro

Package Overview
Dependencies
Maintainers
5
Versions
293
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-server-micro - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

2

dist/microApollo.js

@@ -104,3 +104,3 @@ "use strict";

return function (req, res) {
var query = req.url && url.parse(req.url, true).query || {};
var query = (req.url && url.parse(req.url, true).query) || {};
return GraphiQL.resolveGraphiQLString(query, options, req).then(function (graphiqlString) {

@@ -107,0 +107,0 @@ res.setHeader('Content-Type', 'text/html');

{
"name": "apollo-server-micro",
"version": "1.3.2",
"version": "1.3.3",
"description": "Production-ready Node.js GraphQL server for Micro",

@@ -28,9 +28,9 @@ "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"
},
"devDependencies": {
"@types/graphql": "0.11.7",
"@types/graphql": "0.12.6",
"@types/micro": "7.3.1",
"apollo-server-integration-testsuite": "^1.3.2",
"apollo-server-integration-testsuite": "^1.3.3",
"micro": "8.0.4",

@@ -37,0 +37,0 @@ "microrouter": "2.2.3"

@@ -30,4 +30,4 @@ ---

get('/graphiql', graphiqlHandler),
(req, res) => send(res, 404, 'not found')
)
(req, res) => send(res, 404, 'not found'),
),
);

@@ -34,0 +34,0 @@

@@ -5,34 +5,47 @@ import { microGraphql, microGraphiql } from './microApollo';

import micro, { send } from 'micro';
import { router, get, post, put, patch, del, head, options as opts } from 'microrouter';
import testSuite, { schema, CreateAppOptions } from 'apollo-server-integration-testsuite';
import {
router,
get,
post,
put,
patch,
del,
head,
options as opts,
} from 'microrouter';
import testSuite, {
schema,
CreateAppOptions,
} from 'apollo-server-integration-testsuite';
function createApp(options: CreateAppOptions) {
const graphqlOptions = (options && options.graphqlOptions) || { schema };
const graphiqlOptions = (options && options.graphiqlOptions) || { endpointURL: '/graphql' };
const graphqlOptions = (options && options.graphqlOptions) || { schema };
const graphiqlOptions = (options && options.graphiqlOptions) || {
endpointURL: '/graphql',
};
const graphqlHandler = microGraphql(graphqlOptions);
const graphiqlHandler = microGraphiql(graphiqlOptions);
const graphqlHandler = microGraphql(graphqlOptions);
const graphiqlHandler = microGraphiql(graphiqlOptions);
return micro(
router(
get('/graphql', graphqlHandler),
post('/graphql', graphqlHandler),
put('/graphql', graphqlHandler),
patch('/graphql', graphqlHandler),
del('/graphql', graphqlHandler),
head('/graphql', graphqlHandler),
opts('/graphql', graphqlHandler),
return micro(
router(
get('/graphql', graphqlHandler),
post('/graphql', graphqlHandler),
put('/graphql', graphqlHandler),
patch('/graphql', graphqlHandler),
del('/graphql', graphqlHandler),
head('/graphql', graphqlHandler),
opts('/graphql', graphqlHandler),
get('/graphiql', graphiqlHandler),
post('/graphiql', graphiqlHandler),
put('/graphiql', graphiqlHandler),
patch('/graphiql', graphiqlHandler),
del('/graphiql', graphiqlHandler),
head('/graphiql', graphiqlHandler),
opts('/graphiql', graphiqlHandler),
get('/graphiql', graphiqlHandler),
post('/graphiql', graphiqlHandler),
put('/graphiql', graphiqlHandler),
patch('/graphiql', graphiqlHandler),
del('/graphiql', graphiqlHandler),
head('/graphiql', graphiqlHandler),
opts('/graphiql', graphiqlHandler),
(req, res) => send(res, 404, 'not found'),
),
);
(req, res) => send(res, 404, 'not found'),
),
);
}

@@ -39,0 +52,0 @@

@@ -1,6 +0,10 @@

import { GraphQLOptions, HttpQueryError, runHttpQuery } from 'apollo-server-core';
import {
GraphQLOptions,
HttpQueryError,
runHttpQuery,
} from 'apollo-server-core';
import * as GraphiQL from 'apollo-server-module-graphiql';
import { createError, json, RequestHandler } from 'micro';
import * as url from 'url';
import {IncomingMessage, ServerResponse} from 'http';
import { IncomingMessage, ServerResponse } from 'http';

@@ -11,3 +15,5 @@ export interface MicroGraphQLOptionsFunction {

export function microGraphql(options: GraphQLOptions | MicroGraphQLOptionsFunction): RequestHandler {
export function microGraphql(
options: GraphQLOptions | MicroGraphQLOptionsFunction,
): RequestHandler {
if (!options) {

@@ -18,6 +24,8 @@ throw new Error('Apollo Server requires options.');

if (arguments.length > 1) {
throw new Error(`Apollo Server expects exactly one argument, got ${arguments.length}`);
throw new Error(
`Apollo Server expects exactly one argument, got ${arguments.length}`,
);
}
return async function (req: IncomingMessage, res: ServerResponse) {
return async function(req: IncomingMessage, res: ServerResponse) {
let query;

@@ -46,3 +54,3 @@ if (req.method === 'POST') {

if (error.headers) {
Object.keys(error.headers).forEach((header) => {
Object.keys(error.headers).forEach(header => {
res.setHeader(header, error.headers[header]);

@@ -63,18 +71,25 @@ });

export interface MicroGraphiQLOptionsFunction {
(req?: IncomingMessage): GraphiQL.GraphiQLData | Promise<GraphiQL.GraphiQLData>;
(req?: IncomingMessage):
| GraphiQL.GraphiQLData
| Promise<GraphiQL.GraphiQLData>;
}
export function microGraphiql(options: GraphiQL.GraphiQLData | MicroGraphiQLOptionsFunction): RequestHandler {
export function microGraphiql(
options: GraphiQL.GraphiQLData | MicroGraphiQLOptionsFunction,
): RequestHandler {
return (req: IncomingMessage, res: ServerResponse) => {
const query = req.url && url.parse(req.url, true).query || {};
return GraphiQL.resolveGraphiQLString(query, options, req).then(graphiqlString => {
res.setHeader('Content-Type', 'text/html');
res.write(graphiqlString);
res.end();
}, error => {
res.statusCode = 500;
res.write(error.message);
res.end();
});
const query = (req.url && url.parse(req.url, true).query) || {};
return GraphiQL.resolveGraphiQLString(query, options, req).then(
graphiqlString => {
res.setHeader('Content-Type', 'text/html');
res.write(graphiqlString);
res.end();
},
error => {
res.statusCode = 500;
res.write(error.message);
res.end();
},
);
};
}

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