Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowFeatured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App Show

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
TypeScript GraphQL Server

TypeScript GraphQL Server

Build type-safe GraphQL APIs with TypeScript, Apollo Server, and automated type generation.

TypeScriptGraphQLApolloBackend
by Community
⭐0Stars
👁️1Views
.antigravity
# TypeScript GraphQL Server

Build type-safe GraphQL APIs with TypeScript using Google Antigravity IDE. This comprehensive guide covers schema design, resolvers, authentication, and performance optimization.

## Why TypeScript GraphQL?

GraphQL with TypeScript provides end-to-end type safety. Google Antigravity IDE's Gemini 3 engine generates resolvers and validates schema consistency automatically.

## Schema Definition

```typescript
// src/schema/typeDefs.ts
import { gql } from "graphql-tag";

export const typeDefs = gql`
  scalar DateTime
  scalar JSON

  type Query {
    user(id: ID!): User
    users(filter: UserFilter, pagination: PaginationInput): UserConnection!
    me: User
  }

  type Mutation {
    createUser(input: CreateUserInput!): User!
    updateUser(id: ID!, input: UpdateUserInput!): User!
    deleteUser(id: ID!): Boolean!
    login(email: String!, password: String!): AuthPayload!
  }

  type Subscription {
    userCreated: User!
    userUpdated(id: ID!): User!
  }

  type User {
    id: ID!
    email: String!
    name: String!
    role: UserRole!
    posts(first: Int, after: String): PostConnection!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type Post {
    id: ID!
    title: String!
    content: String!
    author: User!
    publishedAt: DateTime
  }

  type AuthPayload {
    token: String!
    user: User!
  }

  type UserConnection {
    edges: [UserEdge!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type UserEdge {
    node: User!
    cursor: String!
  }

  type PageInfo {
    hasNextPage: Boolean!
    hasPreviousPage: Boolean!
    startCursor: String
    endCursor: String
  }

  input CreateUserInput {
    email: String!
    password: String!
    name: String!
    role: UserRole
  }

  input UpdateUserInput {
    name: String
    role: UserRole
  }

  input UserFilter {
    email: String
    name: String
    role: UserRole
  }

  input PaginationInput {
    first: Int
    after: String
    last: Int
    before: String
  }

  enum UserRole {
    ADMIN
    USER
    GUEST
  }
`;
```

## Resolvers with DataLoader

```typescript
// src/resolvers/userResolvers.ts
import { Resolvers, UserResolvers } from "../generated/graphql";
import { Context } from "../context";
import DataLoader from "dataloader";

// Create DataLoader to batch user queries
function createUserLoader(db: Database) {
  return new DataLoader<string, User>(async (ids) => {
    const users = await db.user.findMany({
      where: { id: { in: [...ids] } },
    });
    
    const userMap = new Map(users.map((u) => [u.id, u]));
    return ids.map((id) => userMap.get(id) || null);
  });
}

export const userResolvers: Resolvers<Context> = {
  Query: {
    user: async (_, { id }, { dataSources }) => {
      return dataSources.userLoader.load(id);
    },
    
    users: async (_, { filter, pagination }, { db }) => {
      const { first = 20, after } = pagination || {};
      
      const users = await db.user.findMany({
        where: filter ? buildFilter(filter) : undefined,
        take: first + 1,
        cursor: after ? { id: after } : undefined,
        orderBy: { createdAt: "desc" },
      });
      
      const hasNextPage = users.length > first;
      const edges = users.slice(0, first).map((user) => ({
        node: user,
        cursor: user.id,
      }));
      
      return {
        edges,
        pageInfo: {
          hasNextPage,
          hasPreviousPage: !!after,
          startCursor: edges[0]?.cursor,
          endCursor: edges[edges.length - 1]?.cursor,
        },
        totalCount: await db.user.count(),
      };
    },
    
    me: async (_, __, { user }) => {
      if (!user) throw new AuthenticationError("Not authenticated");
      return user;
    },
  },
  
  Mutation: {
    createUser: async (_, { input }, { db, pubsub }) => {
      const user = await db.user.create({
        data: {
          ...input,
          password: await hashPassword(input.password),
        },
      });
      
      pubsub.publish("USER_CREATED", { userCreated: user });
      return user;
    },
  },
  
  Subscription: {
    userCreated: {
      subscribe: (_, __, { pubsub }) => 
        pubsub.asyncIterator(["USER_CREATED"]),
    },
  },
  
  User: {
    posts: async (parent, { first, after }, { db }) => {
      // Resolve posts for user
      return db.post.findMany({
        where: { authorId: parent.id },
        take: first || 10,
      });
    },
  },
};
```

## Context and Authentication

```typescript
// src/context.ts
import { PrismaClient } from "@prisma/client";
import { PubSub } from "graphql-subscriptions";
import { verifyToken } from "./auth";

export interface Context {
  db: PrismaClient;
  pubsub: PubSub;
  user: User | null;
  dataSources: {
    userLoader: DataLoader<string, User>;
  };
}

export async function createContext({ req }): Promise<Context> {
  const token = req.headers.authorization?.replace("Bearer ", "");
  const user = token ? await verifyToken(token) : null;
  
  return {
    db: prisma,
    pubsub: new PubSub(),
    user,
    dataSources: {
      userLoader: createUserLoader(prisma),
    },
  };
}
```

## Best Practices

- Use DataLoader to prevent N+1 queries
- Implement cursor-based pagination
- Apply field-level authorization
- Use code generation for type safety
- Cache frequently accessed data
- Monitor query complexity and depth

Google Antigravity IDE provides GraphQL schema validation and automatically generates TypeScript types from your schema.

When to Use This Prompt

This TypeScript prompt is ideal for developers working on:

  • TypeScript applications requiring modern best practices and optimal performance
  • Projects that need production-ready TypeScript code with proper error handling
  • Teams looking to standardize their typescript development workflow
  • Developers wanting to learn industry-standard TypeScript patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their typescript implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the TypeScript code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this TypeScript prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For TypeScript projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...