---
name: graphql-mobile
description: GraphQL client integration for mobile applications
version: 1.0.0
category: API Integration
slug: graphql-mobile
status: active
graph:
  domains: [domain:mobile]
  specializations: [specialization:mobile-development]
  skillAreas: [skill-area:react-native-development, skill-area:data-fetching-caching]
  roles: [role:mobile-engineer]
  workflows: [workflow:feature-development, workflow:release-management]
  topics: [topic:accessibility]
---

# GraphQL Mobile Skill

## Overview

This skill provides GraphQL client integration capabilities for mobile applications. It enables configuration of Apollo Client, code generation, caching strategies, and real-time subscriptions.

## Allowed Tools

- `bash` - Execute codegen and build tools
- `read` - Analyze GraphQL schemas and queries
- `write` - Generate typed operations and configurations
- `edit` - Update GraphQL implementations
- `glob` - Search for GraphQL files
- `grep` - Search for patterns

## Capabilities

### Apollo Client (React Native)

1. **Client Configuration**
   - Configure Apollo Client
   - Set up HTTP and WebSocket links
   - Configure authentication
   - Handle error policies

2. **Caching**
   - Configure InMemoryCache
   - Implement type policies
   - Handle cache normalization
   - Configure persistence

### Code Generation

3. **GraphQL Codegen**
   - Generate TypeScript types
   - Generate React hooks
   - Generate fragments
   - Handle custom scalars

### Flutter GraphQL

4. **graphql_flutter**
   - Configure GraphQL client
   - Implement queries and mutations
   - Handle subscriptions
   - Configure caching

### Native Clients

5. **Apollo iOS**
   - Configure Apollo iOS client
   - Generate Swift types
   - Handle caching
   - Implement subscriptions

6. **Apollo Android**
   - Configure Apollo Kotlin client
   - Generate Kotlin types
   - Handle normalized cache

### Real-time

7. **Subscriptions**
   - Configure WebSocket links
   - Handle reconnection
   - Implement subscription hooks
   - Manage active subscriptions

## Target Processes

- `graphql-apollo-integration.js` - GraphQL implementation
- `offline-first-architecture.js` - Offline caching
- `mobile-performance-optimization.js` - Query optimization

## Dependencies

- Apollo Client
- GraphQL Codegen
- Platform-specific GraphQL libraries

## Usage Examples

### Apollo Client Setup (React Native)

```typescript
// apollo/client.ts
import { ApolloClient, InMemoryCache, createHttpLink, split } from '@apollo/client';
import { GraphQLWsLink } from '@apollo/client/link/subscriptions';
import { getMainDefinition } from '@apollo/client/utilities';
import { setContext } from '@apollo/client/link/context';
import { createClient } from 'graphql-ws';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { AsyncStorageWrapper, CachePersistor } from 'apollo3-cache-persist';

const httpLink = createHttpLink({
  uri: 'https://api.example.com/graphql',
});

const wsLink = new GraphQLWsLink(
  createClient({
    url: 'wss://api.example.com/graphql',
    connectionParams: async () => {
      const token = await AsyncStorage.getItem('authToken');
      return { authorization: token ? `Bearer ${token}` : '' };
    },
  })
);

const authLink = setContext(async (_, { headers }) => {
  const token = await AsyncStorage.getItem('authToken');
  return {
    headers: {
      ...headers,
      authorization: token ? `Bearer ${token}` : '',
    },
  };
});

const splitLink = split(
  ({ query }) => {
    const definition = getMainDefinition(query);
    return definition.kind === 'OperationDefinition' && definition.operation === 'subscription';
  },
  wsLink,
  authLink.concat(httpLink)
);

const cache = new InMemoryCache({
  typePolicies: {
    Query: {
      fields: {
        posts: {
          keyArgs: false,
          merge(existing = [], incoming) {
            return [...existing, ...incoming];
          },
        },
      },
    },
  },
});

export const persistor = new CachePersistor({
  cache,
  storage: new AsyncStorageWrapper(AsyncStorage),
});

export const client = new ApolloClient({
  link: splitLink,
  cache,
  defaultOptions: {
    watchQuery: {
      fetchPolicy: 'cache-and-network',
    },
  },
});
```

### GraphQL Codegen Configuration

```yaml
# codegen.yml
schema: https://api.example.com/graphql
documents: 'src/**/*.graphql'
generates:
  src/generated/graphql.ts:
    plugins:
      - typescript
      - typescript-operations
      - typescript-react-apollo
    config:
      withHooks: true
      withComponent: false
      withHOC: false
      skipTypename: false
      dedupeFragments: true
```

### Query Hook Usage

```typescript
// features/posts/hooks/usePosts.ts
import { usePostsQuery, useCreatePostMutation } from '../../../generated/graphql';

export function usePosts() {
  const { data, loading, error, refetch, fetchMore } = usePostsQuery({
    variables: { first: 10 },
    notifyOnNetworkStatusChange: true,
  });

  const [createPost] = useCreatePostMutation({
    update(cache, { data }) {
      cache.modify({
        fields: {
          posts(existingPosts = []) {
            const newPostRef = cache.writeFragment({
              data: data?.createPost,
              fragment: PostFragmentDoc,
            });
            return [newPostRef, ...existingPosts];
          },
        },
      });
    },
    optimisticResponse: (variables) => ({
      __typename: 'Mutation',
      createPost: {
        __typename: 'Post',
        id: 'temp-id',
        title: variables.title,
        body: variables.body,
        createdAt: new Date().toISOString(),
      },
    }),
  });

  const loadMore = () => {
    if (data?.posts.pageInfo.hasNextPage) {
      fetchMore({
        variables: {
          after: data.posts.pageInfo.endCursor,
        },
      });
    }
  };

  return {
    posts: data?.posts.edges.map((e) => e.node) ?? [],
    loading,
    error,
    refetch,
    loadMore,
    createPost,
  };
}
```

### Apollo iOS Setup

```swift
// Apollo/Network.swift
import Apollo
import ApolloWebSocket

class Network {
    static let shared = Network()

    private(set) lazy var apollo: ApolloClient = {
        let store = ApolloStore(cache: InMemoryNormalizedCache())

        let provider = DefaultInterceptorProvider(store: store)
        let url = URL(string: "https://api.example.com/graphql")!

        let transport = RequestChainNetworkTransport(
            interceptorProvider: provider,
            endpointURL: url
        )

        return ApolloClient(networkTransport: transport, store: store)
    }()
}
```

## Quality Gates

- Type safety via codegen
- Query complexity limits
- Cache consistency verified
- Subscription reconnection tested

## Related Skills

- `rest-api-integration` - REST integration
- `offline-storage` - Offline caching
- `firebase-mobile` - Firebase alternative

## Version History

- 1.0.0 - Initial release


---
Source attribution: a5c-ai
Original project: https://github.com/a5c-ai/babysitter/blob/feb68abe397acc14f32b34984975c48fedba2b33/library/specializations/mobile-development/skills/graphql-mobile/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Dave AI.

## Upstream license notice

# MIT License

Copyright (c) 2025 A5C AI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Dave AI resource metadata

Creator / publisher: a5c-ai
Original project: https://github.com/a5c-ai/babysitter/blob/feb68abe397acc14f32b34984975c48fedba2b33/library/specializations/mobile-development/skills/graphql-mobile/SKILL.md
Attribution basis: Recovered original package and original project license at a pinned revision

Fields of work: Development & Engineering, Product Management
Roles: Backend Developer, Mobile Developer, Product Manager
Specialties: API, Backend, Mobile
Tools: Apollo Client, Graphql Codegen
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 4bcca996313bfd6bf555d610c6678c5b025d8fd6019cc99368d34d12c5846f98
Metadata reviewed: 2026-10-27
This metadata supersedes earlier Dave AI catalog attribution. Original instruction and supporting files are preserved.
