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.25 to 1.0.26

45

__tests__/mammothgql.spec.ts

@@ -14,3 +14,3 @@ import request from 'supertest';

Query: {
hello: (_: never, { s }: { s: string }) => s,
hello: (_: unknown, { s }: { s: string }) => s,
},

@@ -20,13 +20,12 @@ },

interface ServerContext extends MammothBaseContext {
userId?: string;
}
describe('mammothGraphql Middleware', () => {
let app: express.Express;
beforeAll(() => {
beforeEach(() => {
app = express();
app.use(json());
interface ServerContext extends MammothBaseContext {
user?: any;
}
app.use(

@@ -42,3 +41,3 @@ '/graphql',

it('should return a valid response', async () => {
it('should return a valid response with the correct data', async () => {
const response = await request(app)

@@ -48,3 +47,5 @@ .post('/graphql')

query: 'query Hello($s: String!) { hello(s: $s) }',
variables: { s: 'normally encoded' },
variables: {
s: 'world!',
},
})

@@ -54,6 +55,22 @@ .expect(200);

expect(response.body.data).toEqual({
hello: 'normally encoded',
hello: 'world!',
});
expect(response.body.errors).toBeUndefined();
});
it('should return an error for missing required variable in the query', async () => {
const response = await request(app)
.post('/graphql')
.send({
query: 'query Hello($s: String!) { hello(s: $s) }',
})
.expect(400);
expect(response.body.errors).toBeDefined();
expect(response.body.errors[0].message).toContain(
'Variable "$s" of required type "String!" was not provided.',
);
});
it('should serve the GraphiQL interface when graphiql is true', async () => {

@@ -64,2 +81,10 @@ const response = await request(app).get('/graphql').expect(200);

});
it('should return a 404 for a non-existent GraphQL endpoint', async () => {
const response = await request(app)
.get('/non-existent-endpoint')
.expect(404);
expect(response.status).toBe(404);
});
});

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

## [1.0.26](https://github.com/freshsqueezed/mammothgql/compare/v1.0.25...v1.0.26) (2025-01-17)
### Bug Fixes
* **context:** update context for optional ([0425aef](https://github.com/freshsqueezed/mammothgql/commit/0425aef1c8affd1deb9f90c55ae360bbe415f2ad))
## [1.0.25](https://github.com/freshsqueezed/mammothgql/compare/v1.0.24...v1.0.25) (2025-01-08)

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

@@ -9,3 +9,3 @@ import { Request, Response } from 'express';

schema: GraphQLSchema;
context: (args: MammothBaseContext) => Partial<ServerContext>;
context?: (args: MammothBaseContext) => Partial<ServerContext>;
pretty?: boolean;

@@ -12,0 +12,0 @@ graphiql?: boolean;

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

function mammothGraphql(options) {
const { schema, pretty = false, graphiql: showGraphiQL = false, validationRules = [], } = options;
const { schema, pretty = false, graphiql: showGraphiQL = true, validationRules = [], } = options;
return async (req, res) => {

@@ -72,3 +72,3 @@ if (req.method !== 'GET' && req.method !== 'POST') {

res,
...options.context({ req, res }),
...(options.context ? options.context({ req, res }) : {}),
};

@@ -75,0 +75,0 @@ const result = await (0, graphql_1.execute)({

import { GraphQLResolveInfo } from 'graphql';
export type FilterFn<TSource, TArgs, TContext> = (rootValue: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => boolean | Promise<boolean>;
export type ResolverFn<TSource, TArgs, TContext> = (rootValue: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => AsyncIterator<any> | Promise<AsyncIterator<any>>;
export type IterableResolverFn<TSource, TArgs, TContext> = (rootValue: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => AsyncIterableIterator<any> | Promise<AsyncIterableIterator<any>>;
export type WithFilter<TSource, TArgs, TContext> = (asyncIteratorFn: ResolverFn<TSource, TArgs, TContext>, filterFn: FilterFn<TSource, TArgs, TContext>) => IterableResolverFn<TSource, TArgs, TContext>;
type FilterFn<TSource, TArgs, TContext> = (rootValue: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => boolean | Promise<boolean>;
type ResolverFn<TSource, TArgs, TContext> = (rootValue: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => AsyncIterator<any> | Promise<AsyncIterator<any>>;
type IterableResolverFn<TSource, TArgs, TContext> = (rootValue: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => AsyncIterableIterator<any> | Promise<AsyncIterableIterator<any>>;
export declare function withFilter<TSource, TArgs, TContext>(asyncIteratorFn: ResolverFn<TSource, TArgs, TContext>, filterFn: FilterFn<TSource, TArgs, TContext>): IterableResolverFn<TSource, TArgs, TContext>;
export {};
//# sourceMappingURL=with-filter.d.ts.map

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

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

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

@@ -27,3 +27,3 @@ import { Request, Response } from 'express';

schema: GraphQLSchema;
context: (args: MammothBaseContext) => Partial<ServerContext>;
context?: (args: MammothBaseContext) => Partial<ServerContext>;
pretty?: boolean;

@@ -40,3 +40,3 @@ graphiql?: boolean;

pretty = false,
graphiql: showGraphiQL = false,
graphiql: showGraphiQL = true,
validationRules = [],

@@ -126,3 +126,3 @@ } = options;

res,
...options.context({ req, res }),
...(options.context ? options.context({ req, res }) : {}),
} as ServerContext;

@@ -129,0 +129,0 @@

import { GraphQLResolveInfo } from 'graphql';
export type FilterFn<TSource, TArgs, TContext> = (
type FilterFn<TSource, TArgs, TContext> = (
rootValue: TSource,

@@ -10,3 +10,3 @@ args: TArgs,

export type ResolverFn<TSource, TArgs, TContext> = (
type ResolverFn<TSource, TArgs, TContext> = (
rootValue: TSource,

@@ -18,3 +18,3 @@ args: TArgs,

export type IterableResolverFn<TSource, TArgs, TContext> = (
type IterableResolverFn<TSource, TArgs, TContext> = (
rootValue: TSource,

@@ -30,7 +30,2 @@ args: TArgs,

export type WithFilter<TSource, TArgs, TContext> = (
asyncIteratorFn: ResolverFn<TSource, TArgs, TContext>,
filterFn: FilterFn<TSource, TArgs, TContext>,
) => IterableResolverFn<TSource, TArgs, TContext>;
export function withFilter<TSource, TArgs, TContext>(

@@ -37,0 +32,0 @@ asyncIteratorFn: ResolverFn<TSource, TArgs, TContext>,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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