grng - Pronounced like "grunge". This is a lightweight, Angular-native GraphQL client designed to seamlessly integrate with Angular 19’s resource API. It provides a minimalistic and efficient way to manage GraphQL queries, mutations, and subscriptions using Angular’s reactivity model. The goal is to reduce boilerplate, enhance developer experience, and ensure optimal performance with Signals and RxJS.
- Native support for
resource(), leveraging Signals for reactivity. - Declarative API that simplifies GraphQL operations.
- Short and intuitive function names:
queryResource,mutateResource,query$, andmutate$. - No unnecessary decorators or complex configurations.
- Signal-based API: Uses
resource()for automatic reactivity. - RxJS-based API: Returns
Observablefor flexibility in streaming data.
- Optional caching mechanism with auto-invalidation.
- Fine-grained control over fetch policies (
network-only,cache-first, etc.).
- Strongly typed queries and mutations.
- Seamless integration with GraphQL Codegen.
subResourceandsub$for GraphQL subscriptions.- Real-time updates with WebSockets.
- Optimized for server-side rendering with Angular Universal.
- Automatic state hydration on the client.
- Works with
fetch(),HttpClient, or custom transport strategies. - Easy authentication handling via interceptors or headers.
npm install grngimport { queryResource } from 'grng';
import { signal, Injectable } from '@angular/core';
@Injectable({ providedIn: 'root' })
export class UserService {
getUser = queryResource<{ user: User }>(gql`
query GetUser($id: ID!) {
user(id: $id) {
id
name
}
}
`, { id: signal('123') });
}import { mutateResource } from 'grng';
@Injectable({ providedIn: 'root' })
export class UserService {
updateUser = mutateResource<{ updateUser: User }>(gql`
mutation UpdateUser($id: ID!, $input: UserInput!) {
updateUser(id: $id, input: $input) {
id
name
}
}
`);
}import { query$ } from 'grng';
@Injectable({ providedIn: 'root' })
export class UserService {
getUser$ = query$<{ user: User }>(gql`
query GetUser($id: ID!) {
user(id: $id) {
id
name
}
}
`, { id: '123' });
}import { mutate$ } from 'grng';
@Injectable({ providedIn: 'root' })
export class UserService {
updateUser$ = mutate$<{ updateUser: User }>(gql`
mutation UpdateUser($id: ID!, $input: UserInput!) {
updateUser(id: $id, input: $input) {
id
name
}
}
`);
}We welcome contributions! Feel free to open issues and submit pull requests.
MIT License
