Command Palette

Search for a command to run...

Назад к скиллам
скилл № 45145

graphql-architect

Use proactively for GraphQL API design, schema optimization, or N+1 query issues. Designs schemas, resolvers, and subscriptions using graphql-ruby patterns.

БесплатноБез исполняемых скриптов
majesticlabs-devот majesticlabs-dev★ 50 звёзд на GitHub

Установить graphql-architect в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

GraphQL Architect for Rails

Audience: Rails developers building GraphQL APIs Goal: Design schemas, resolvers, and subscriptions using graphql-ruby best practices

Key Capabilities

  1. Design GraphQL schemas with proper types, interfaces, and unions
  2. Prevent N+1 queries using graphql-batch or batch-loader patterns
  3. Implement subscriptions with ActionCable integration
  4. Set up authorization with Pundit or custom policies
  5. Configure pagination using connections and cursor-based patterns

Schema Design

Type Definitions

module Types
  class UserType < Types::BaseObject
    field :id, ID, null: false
    field :email, String, null: false
    field :posts, [Types::PostType], null: false
    field :created_at, GraphQL::Types::ISO8601DateTime, null: false
  end
end

Query Root

module Types
  class QueryType < Types::BaseObject
    field :user, Types::UserType, null: true do
      argument :id, ID, required: true
    end

    field :users, Types::UserType.connection_type, null: false

    def user(id:) = User.find_by(id: id)
    def users = User.all
  end
end

Mutations

module Mutations
  class CreateUser < BaseMutation
    argument :email, String, required: true
    field :user, Types::UserType, null: true
    field :errors, [String], null: false

    def resolve(email:)
      user = User.new(email: email)
      user.save ? { user:, errors: [] } : { user: nil, errors: user.errors.full_messages }
    end
  end
end

N+1 Prevention with graphql-batch

# app/graphql/loaders/association_loader.rb
class Loaders::AssociationLoader < GraphQL::Batch::Loader
  def initialize(model, association_name)
    @model = model
    @association_name = association_name
  end

  def perform(records)
    preloader = ActiveRecord::Associations::Preloader.new(records:, associations: @association_name)
    preloader.call
    records.each { |record| fulfill(record, record.send(@association_name)) }
  end
end

# Usage in type
class Types::UserType < Types::BaseObject
  field :posts, [Types::PostType], null: false

  def posts
    Loaders::AssociationLoader.for(User, :posts).load(object)
  end
end

ActionCable Subscriptions

module Types
  class SubscriptionType < Types::BaseObject
    field :post_created, Types::PostType, null: false
    def post_created = object
  end
end

# Triggering
AppSchema.subscriptions.trigger(:post_created, {}, post)

Authorization

class Types::BaseObject < GraphQL::Schema::Object
  def self.authorized?(object, context)
    Pundit.policy(context[:current_user], object).show?
  end
end

Pagination (Connections)

field :posts, Types::PostType.connection_type, null: false do
  argument :status, Types::PostStatusEnum, required: false
end

def posts(status: nil)
  scope = Post.all
  scope = scope.where(status:) if status
  scope.order(created_at: :desc)
end

Error Handling

class AppSchema < GraphQL::Schema
  rescue_from ActiveRecord::RecordNotFound do |err, obj, args, ctx, field|
    raise GraphQL::ExecutionError, "#{field.type.unwrap.graphql_name} not found"
  end
end

Performance

class AppSchema < GraphQL::Schema
  max_complexity 200
  max_depth 10
end

Deliverables

When designing GraphQL APIs, provide:

  1. Schema Definition: Types, queries, mutations
  2. N+1 Prevention: Loader implementations
  3. Authorization: Access control
  4. Subscriptions: Real-time features
  5. Testing: RSpec examples
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

  1. 01Read
  2. 02Write
  3. 03Edit
  4. 04Grep
  5. 05Glob
  6. 06Bash
  7. 07WebSearch

FAQ

Что делает скилл graphql-architect?

Use proactively for GraphQL API design, schema optimization, or N+1 query issues. Designs schemas, resolvers, and subscriptions using graphql-ruby patterns.

Как установить скилл graphql-architect?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл graphql-architect запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить graphql-architect с