graphql-query-pattern

Standardizes AniList GraphQL queries and mutations from Retrofit to Room with error propagation.

51|6|Updated Mar 10, 2019
One-click install
npx skills add https://github.com/AniTrend/anitrend-v2 --skill graphql-query-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: graphql-query-pattern
Source: https://github.com/AniTrend/anitrend-v2/tree/main/.agents/skills/graphql-query-pattern
Command: npx skills add https://github.com/AniTrend/anitrend-v2 --skill graphql-query-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) and references (resource) components.

What problem does it solve?

It prevents fragile, one-off GraphQL handling by providing a consistent controller-and-mapper lifecycle for every AniList query and mutation, including reliable error propagation and safe Room persistence.

Core Features & Use Cases

  • Request lifecycle standardization: Validates GraphQLResponse, converts results via a mapper, persists to Room, and emits domain models through DataState.
  • Remote source binding clarity: Keeps Retrofit tags, operation name resolution, QueryContainerBuilder variables, and asset-backed .graphql queries synchronized.
  • Mutation and edge modeling rules: Guides how to structure mutations, domain contracts, mapping/persistence responsibilities, and remote-to-local model fidelity.

Quick Start

Apply the GraphQL Query / Controller Pattern when adding a new AniList GraphQL request by defining a Retrofit @GraphQuery interface method, placing the .graphql file under assets/graphql, and executing the call through GraphQLController with the correct mapper and dispatcher.

Frequently Asked Questions about graphql-query-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize AniList GraphQL queries with Retrofit and Room persistence?

Standardize AniList GraphQL queries by defining Retrofit @GraphQuery methods, placing operations in assets/graphql, and executing via GraphQLController to persist mapped entities in Room. This controller pattern handles validation, mapping, and threading centrally to ensure consistent data flows.

What is the best way to handle GraphQL errors from AniList in an Android controller?

Handle GraphQL errors by validating GraphQLResponse within GraphQLController, extracting non-null data, and converting GraphQL errors into RequestError. This prevents manual unwrapping in data sources and safely propagates errors through DataState domain flows.

How do I pass variables to AniList GraphQL mutations using QueryContainerBuilder?

Pass variables to GraphQL mutations by assembling QueryContainerBuilder variables via IGraphPayload.toMap. This keeps operation name resolution synchronized with Retrofit tags and asset-backed .graphql queries for reliable remote source bindings.

How does GraphQLController manage threading and Room persistence for network requests?

GraphQLController manages threading centrally and persists mapped remote-to-local models into Room after validating the GraphQLResponse. It prevents manual unwrapping in data sources and emits final domain models through DataState.

Can I manually unwrap Response<GraphQLResponse<*>> in my Retrofit data sources?

No, you should not manually unwrap Response<GraphQLResponse<*>> in data sources. The GraphQLController pattern requires centralized validation of non-null data and safe error extraction to prevent fragile, one-off GraphQL handling.

Where should I place .graphql files for AniList queries in an Android project?

Place .graphql files under the assets/graphql directory to synchronize them with Retrofit @GraphQuery interface methods. This asset-backed approach ensures operation name resolution and QueryContainerBuilder variables are correctly bound.