New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@freshsqueezed/mammothgql

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@freshsqueezed/mammothgql - npm Package Compare versions

Comparing version 1.0.5 to 1.0.7

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [1.0.7](https://github.com/freshsqueezed/mammothgql/compare/v1.0.6...v1.0.7) (2024-12-18)
### Bug Fixes
* **html:** Remove redundant html ([49da316](https://github.com/freshsqueezed/mammothgql/commit/49da31626f321ce6d80f3737a6263e53d57fa245))
## [1.0.5](https://github.com/freshsqueezed/mammothgql/compare/v1.0.4...v1.0.5) (2024-12-18)

@@ -2,0 +9,0 @@

1

lib/mammoth.d.ts

@@ -14,3 +14,4 @@ import { NextFunction, Request, Response } from 'express';

export declare function mammothGraphql<TContext>(options: MammothOptions<TContext>): (req: Request, res: Response, next: NextFunction) => Promise<void>;
export declare function graphiqlHtml(req: Request, res: Response): void;
export {};
//# sourceMappingURL=mammoth.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mammothGraphql = mammothGraphql;
exports.graphiqlHtml = graphiqlHtml;
const graphql_1 = require("graphql");
const html_1 = require("./html");
function mammothGraphql(options) {

@@ -18,3 +18,3 @@ const { schema, pretty = false, graphiql: showGraphiQL = false, validationRules = [], } = options;

if (showGraphiQL && req.method === 'GET') {
(0, html_1.graphiqlHtml)(req, res);
graphiqlHtml(req, res);
return;

@@ -68,3 +68,3 @@ }

try {
const result = await (0, graphql_1.execute)({
const result = (await (0, graphql_1.execute)({
schema,

@@ -75,3 +75,3 @@ document: documentAST,

operationName,
});
}));
if (!result.data && result.errors) {

@@ -102,2 +102,85 @@ res.status(500).json(createErrorMessages(result.errors.map((e) => e.message), result.errors));

});
function graphiqlHtml(req, res) {
const protocol = req.protocol;
const host = req.get('host');
const path = req.path;
const fullUrl = `${protocol}://${host}${path}`;
const wsProtocol = protocol === 'https' ? 'wss' : 'ws';
const wsUrl = `${wsProtocol}://${host}${path}`;
res.send(`
<!--
// * Copyright (c) 2024 GraphQL Contributors
// * All rights reserved.
// *
// * This source code is licensed under the license found in the
// * LICENSE file in the root directory of this source tree.
// -->
<!doctype html>
<html lang="en">
<head>
<title>GraphiQL</title>
<style>
body {
height: 100%;
margin: 0;
width: 100%;
overflow: hidden;
}
#graphiql {
height: 100vh;
}
</style>
<script
crossorigin
src="https://unpkg.com/react@18/umd/react.development.js"
></script>
<script
crossorigin
src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"
></script>
<script
src="https://unpkg.com/graphiql/graphiql.min.js"
type="application/javascript"
></script>
<link rel="stylesheet" href="https://unpkg.com/graphiql/graphiql.min.css" />
<script
src="https://unpkg.com/@graphiql/plugin-explorer/dist/index.umd.js"
crossorigin
></script>
<link
rel="stylesheet"
href="https://unpkg.com/@graphiql/plugin-explorer/dist/style.css"
/>
<script src="https://unpkg.com/graphql-ws@5.11.0/umd/graphql-ws.min.js"></script>
</head>
<body>
<div id="graphiql">
<div class="spinner"></div> <!-- Spinner element -->
</div>
<script>
const root = ReactDOM.createRoot(document.getElementById('graphiql'));
const fetcher = GraphiQL.createFetcher({
url: ${fullUrl},
wsClient: graphqlWs.createClient({
url: ${wsUrl},
}),
});
const explorerPlugin = GraphiQLPluginExplorer.explorerPlugin();
root.render(
React.createElement(GraphiQL, {
fetcher,
defaultEditorToolsVisibility: true,
plugins: [explorerPlugin],
})
);
document.querySelector('.spinner').style.display = 'none';
</script>
</body>
</html>
`);
}
//# sourceMappingURL=mammoth.js.map

2

package.json

@@ -6,3 +6,3 @@ {

"types": "lib/index.d.ts",
"version": "1.0.5",
"version": "1.0.7",
"author": "Matt Gordon <matt@lemonade.tech>",

@@ -9,0 +9,0 @@ "license": "MIT",

@@ -19,4 +19,2 @@ import { NextFunction, Request, Response } from 'express';

} from 'graphql';
import { handleValidationErrors } from './utils';
import { graphiqlHtml } from './html';

@@ -83,7 +81,5 @@ interface MammothOptions<TContext> {

error instanceof Error ? error : new Error('Unknown parsing error');
const graphQLError = new GraphQLError(syntaxError.message, {
originalError: syntaxError,
});
res

@@ -99,3 +95,2 @@ .status(400)

]);
if (validationErrors.length > 0) {

@@ -125,3 +120,3 @@ res

try {
const result = await execute({
const result = (await execute({
schema,

@@ -132,3 +127,3 @@ document: documentAST,

operationName,
});
})) as FormattedExecutionResult;

@@ -174,1 +169,86 @@ if (!result.data && result.errors) {

});
export function graphiqlHtml(req: Request, res: Response) {
const protocol = req.protocol;
const host = req.get('host');
const path = req.path;
const fullUrl = `${protocol}://${host}${path}`;
const wsProtocol = protocol === 'https' ? 'wss' : 'ws';
const wsUrl = `${wsProtocol}://${host}${path}`;
res.send(`
<!--
// * Copyright (c) 2024 GraphQL Contributors
// * All rights reserved.
// *
// * This source code is licensed under the license found in the
// * LICENSE file in the root directory of this source tree.
// -->
<!doctype html>
<html lang="en">
<head>
<title>GraphiQL</title>
<style>
body {
height: 100%;
margin: 0;
width: 100%;
overflow: hidden;
}
#graphiql {
height: 100vh;
}
</style>
<script
crossorigin
src="https://unpkg.com/react@18/umd/react.development.js"
></script>
<script
crossorigin
src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"
></script>
<script
src="https://unpkg.com/graphiql/graphiql.min.js"
type="application/javascript"
></script>
<link rel="stylesheet" href="https://unpkg.com/graphiql/graphiql.min.css" />
<script
src="https://unpkg.com/@graphiql/plugin-explorer/dist/index.umd.js"
crossorigin
></script>
<link
rel="stylesheet"
href="https://unpkg.com/@graphiql/plugin-explorer/dist/style.css"
/>
<script src="https://unpkg.com/graphql-ws@5.11.0/umd/graphql-ws.min.js"></script>
</head>
<body>
<div id="graphiql">
<div class="spinner"></div> <!-- Spinner element -->
</div>
<script>
const root = ReactDOM.createRoot(document.getElementById('graphiql'));
const fetcher = GraphiQL.createFetcher({
url: ${fullUrl},
wsClient: graphqlWs.createClient({
url: ${wsUrl},
}),
});
const explorerPlugin = GraphiQLPluginExplorer.explorerPlugin();
root.render(
React.createElement(GraphiQL, {
fetcher,
defaultEditorToolsVisibility: true,
plugins: [explorerPlugin],
})
);
document.querySelector('.spinner').style.display = 'none';
</script>
</body>
</html>
`);
}

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