
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@gnql/graphql-blocks
Advanced tools
A TypeScript library providing GraphQL operations with model abstractions, Apollo Client middleware, and intelligent caching capabilities.
bun install
The @src/graphql module provides comprehensive GraphQL data processing and caching capabilities designed to work seamlessly with Apollo Client.
__typename and id fields)GraphQLCacheUpdater for full Apollo integrationGraphQLCacheUpdater type for basic operationsimport { createGraphQLCacheLink } from '@gnql/graphql-blocks';
import { ApolloClient, from, createHttpLink } from '@apollo/client';
// Implement your cache
class MyCache extends GraphQLCacheUpdater {
private cache = new Map<string, any>();
get(typename: string, id: string | number): any {
return this.cache.get(`${typename}:${id}`);
}
update(typename: string, id: string | number, value: any): void {
this.cache.set(`${typename}:${id}`, value);
}
}
// Create Apollo Client with caching middleware
const httpLink = createHttpLink({ uri: '/graphql' });
const cacheLink = createGraphQLCacheLink(new MyCache());
const client = new ApolloClient({
link: from([cacheLink, httpLink]),
// ... other config
});
import { readGraphQLData } from '@gnql/graphql-blocks';
// Process GraphQL data manually
const cacheHandler = new MyCacheUpdater();
cacheHandler.rootData = {
user: { __typename: 'User', id: '1', name: 'John' },
posts: [
{
__typename: 'Post',
id: '1',
title: 'Hello',
author: { __typename: 'User', id: '1' } // References the same user
}
]
};
const processedData = readGraphQLData(cacheHandler);
// Entities are now cached and cross-references are maintained
import { isGraphQLEntity, isObject, hasCustomId } from '@gnql/graphql-blocks';
// Check if an object is a GraphQL entity
if (isGraphQLEntity(data)) {
console.log(`Entity: ${data.__typename} with ID: ${data.id}`);
}
// Type-safe object checking
if (isObject(value)) {
console.log(value.someProperty); // TypeScript knows this is safe
}
// Custom ID field support
const customIds = new Map([['User', 'userId'], ['Product', 'sku']]);
if (hasCustomId(user, customIds)) {
console.log('User has custom ID field');
}
import { GraphQLCacheUpdater } from '@gnql/graphql-blocks';
class MyCache extends GraphQLCacheUpdater {
private entities = new Map<string, any>();
get(typename: string, id: string | number): any {
return this.entities.get(`${typename}:${id}`);
}
update(typename: string, id: string | number, value: any): void {
const key = `${typename}:${id}`;
if (value === null || value === undefined) {
// Handle deletion
this.entities.delete(key);
} else {
// Handle insertion/update
this.entities.set(key, value);
}
}
onOperationStart(operation: Operation): void {
console.log(`Starting operation: ${operation.operationName}`);
}
onOperationEnd(operation: Operation): void {
console.log(`Completed operation: ${operation.operationName}`);
}
}
import type { GraphQLCacheUpdater } from '@gnql/graphql-blocks';
const simpleCache: GraphQLCacheUpdater = {
cache: new Map(),
get(typename: string, id: string | number) {
return this.cache.get(`${typename}:${id}`);
},
set(typename: string, id: string | number, value: any) {
this.cache.set(`${typename}:${id}`, value);
},
delete(typename: string, id: string | number) {
this.cache.delete(`${typename}:${id}`);
}
};
The library automatically detects and handles circular references in GraphQL data:
// This data structure with circular references is handled automatically
const data = {
user: {
__typename: 'User',
id: '1',
posts: [
{
__typename: 'Post',
id: '1',
author: { __typename: 'User', id: '1' } // Circular reference
}
]
}
};
Support for GraphQL types that use custom ID fields instead of the standard id:
const customIdFields = new Map([
['User', 'userId'],
['Product', 'sku'],
['Order', 'orderNumber']
]);
// The library will recognize these custom ID fields
const product = { __typename: 'Product', sku: 'ABC123', name: 'Widget' };
Full TypeScript support with comprehensive type definitions:
import type {
GraphQLEntity,
GraphQLCacheUpdater,
GraphQLDataHandler
} from '@gnql/graphql-blocks';
// All types are fully typed and documented
const handler: GraphQLDataHandler = (data, updater) => {
// Process data with full type safety
};
# Run tests
bun test
# Build the library
bun run build
# Development mode
bun run dev
This project was created using bun init in bun v1.2.17. Bun is a fast all-in-one JavaScript runtime.
FAQs
Unknown package
We found that @gnql/graphql-blocks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.