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.22 to 1.0.23

7

CHANGELOG.md

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

## [1.0.23](https://github.com/freshsqueezed/mammothgql/compare/v1.0.22...v1.0.23) (2025-01-07)
### Bug Fixes
* **subscription-filter:** add proper typings must release ([3e66d91](https://github.com/freshsqueezed/mammothgql/commit/3e66d91cb45439dac6573d14e953d5d9e31fe999))
## [1.0.22](https://github.com/freshsqueezed/mammothgql/compare/v1.0.21...v1.0.22) (2025-01-07)

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

8

lib/with-filter.d.ts

@@ -0,1 +1,4 @@

interface PubSub {
asyncIterator: (trigger: string) => AsyncIterator<any>;
}
export type FilterFn<TSource = any, TArgs = any, TContext = any> = (rootValue: TSource, args: TArgs, context: TContext, info: any) => boolean | Promise<boolean>;

@@ -5,3 +8,6 @@ export type ResolverFn<TSource = any, TArgs = any, TContext = any> = (rootValue: TSource, args: TArgs, context: TContext, info: any) => AsyncIterator<any> | Promise<AsyncIterator<any>>;

export type WithFilter<TSource = any, TArgs = any, TContext = any> = (asyncIteratorFn: ResolverFn<TSource, TArgs, TContext>, filterFn: FilterFn<TSource, TArgs, TContext>) => IterableResolverFn<TSource, TArgs, TContext>;
export declare function withFilter<TSource = any, TArgs = any, TContext = any>(asyncIteratorFn: ResolverFn<TSource, TArgs, TContext>, filterFn: FilterFn<TSource, TArgs, TContext>): IterableResolverFn<TSource, TArgs, TContext>;
export declare function withFilter<TSource = any, TArgs = any, TContext = {
pubsub: PubSub;
}>(asyncIteratorFn: ResolverFn<TSource, TArgs, TContext>, filterFn: FilterFn<TSource, TArgs, TContext>): IterableResolverFn<TSource, TArgs, TContext>;
export {};
//# sourceMappingURL=with-filter.d.ts.map

8

lib/with-filter.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withFilter = withFilter;
// Modify the withFilter function
function withFilter(asyncIteratorFn, filterFn) {
return async (rootValue, args, context, info) => {
return async (rootValue, args, context, // Context will include pubsub here
info) => {
// Expect the context to have the pubsub property
const asyncIterator = await asyncIteratorFn(rootValue, args, context, info);

@@ -18,7 +21,6 @@ const next = async () => {

};
// Return the AsyncIterableIterator directly, wrapping in Promise.resolve() when done
// Return the AsyncIterableIterator directly
const iterable = {
next,
return() {
// Ensure return is always a Promise of IteratorResult
return asyncIterator.return

@@ -25,0 +27,0 @@ ? asyncIterator.return()

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

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

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

@@ -0,1 +1,7 @@

// Define the type for the pubsub object
interface PubSub {
asyncIterator: (trigger: string) => AsyncIterator<any>;
}
// Define the filter function type
export type FilterFn<TSource = any, TArgs = any, TContext = any> = (

@@ -8,2 +14,3 @@ rootValue: TSource,

// Define the resolver function type
export type ResolverFn<TSource = any, TArgs = any, TContext = any> = (

@@ -16,2 +23,3 @@ rootValue: TSource,

// Define the iterable resolver function type
export type IterableResolverFn<TSource = any, TArgs = any, TContext = any> = (

@@ -24,2 +32,3 @@ rootValue: TSource,

// The withFilter function type definition, expecting a context with pubsub
export type WithFilter<TSource = any, TArgs = any, TContext = any> = (

@@ -30,3 +39,8 @@ asyncIteratorFn: ResolverFn<TSource, TArgs, TContext>,

export function withFilter<TSource = any, TArgs = any, TContext = any>(
// Modify the withFilter function
export function withFilter<
TSource = any,
TArgs = any,
TContext = { pubsub: PubSub },
>(
asyncIteratorFn: ResolverFn<TSource, TArgs, TContext>,

@@ -38,5 +52,6 @@ filterFn: FilterFn<TSource, TArgs, TContext>,

args,
context,
context: TContext, // Context will include pubsub here
info,
): Promise<AsyncIterableIterator<any>> => {
// Expect the context to have the pubsub property
const asyncIterator = await asyncIteratorFn(rootValue, args, context, info);

@@ -57,7 +72,6 @@

// Return the AsyncIterableIterator directly, wrapping in Promise.resolve() when done
// Return the AsyncIterableIterator directly
const iterable: AsyncIterableIterator<any> = {
next,
return() {
// Ensure return is always a Promise of IteratorResult
return asyncIterator.return

@@ -64,0 +78,0 @@ ? asyncIterator.return()

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