承接 adeel3330/graphql-helper-laravel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

adeel3330/graphql-helper-laravel

最新稳定版本:v1.2.2

Composer 安装命令:

composer require adeel3330/graphql-helper-laravel

包简介

Lightweight GraphQL helper layer for Laravel with validation, resolver structure, and response formatting.

README 文档

README

A lightweight helper layer for GraphQL in Laravel — focused on validation, clean resolver structure, and consistent responses.

Not a GraphQL engine. Not a replacement for Lighthouse. Just clean, Laravel-style developer experience.

🚀 Why This Package?

Working with GraphQL in Laravel often leads to:

  • ❌ No standard validation approach
  • ❌ Messy resolver logic
  • ❌ Inconsistent response formats

This package solves that by bringing Laravel-like structure to GraphQL.

🔥 Key Feature: @autoResolver

No more manual resolver mapping.

Instead of writing:

@field(resolver: "App\\GraphQL\\Resolvers\\CreateUserResolver@resolve")

Just use:

@autoResolver

✅ Automatically maps:

createUser → App\GraphQL\Resolvers\CreateUserResolver

✨ Features

  • @autoResolver directive (auto maps GraphQL fields → resolvers)
  • ✅ Artisan generator for resolvers
  • ✅ Laravel-style validation inside resolvers
  • ✅ Clean and consistent resolver structure
  • ✅ Automatic directive namespace registration
  • ✅ Standard response helpers
  • ✅ Plug & play with Lighthouse

📦 Installation

composer require yourname/laravel-graphql-helper

⚙️ Requirements

  • PHP ^8.3 | ^8.4
  • Laravel ^11 | ^12 | ^13
  • Lighthouse GraphQL package

⚙️ Usage

🔹 1. Create a Resolver

php artisan make:graphql-resolver CreateUser

🔹 2. Resolver Example

namespace App\GraphQL\Resolvers;

use App\Models\User;
use Adeel3330\GraphQLHelper\Base\Resolver;

class CreateUserResolver extends Resolver
{
    public function rules(): array
    {
        return [
            'email' => 'required|email',
            'password' => 'required|min:6',
        ];
    }

    public function handle($args)
    {
        return User::create($args);
    }
}

🔹 3. Use in GraphQL Schema

type Mutation {
    createUser(email: String!, password: String!): User @autoResolver
}

🔹 4. Run Mutation

mutation {
  createUser(email: "test@test.com", password: "123456") {
    id
    email
  }
}

🔥 Validation (Automatic)

No need to manually validate — it's handled before execution:

public function rules(): array
{
    return [
        'email' => 'required|email',
    ];
}

📊 Standard Responses

use Adeel3330\GraphQLHelper\Support\GraphQLResponse;

return GraphQLResponse::success($data);

return GraphQLResponse::error('Something went wrong');

🔥 Example Response

{
  "data": {...},
  "message": "Success",
  "status": true
}

🧠 How It Works

  • Reads GraphQL field name (createUser)
  • Converts to class (CreateUserResolver)
  • Resolves from:
App\GraphQL\Resolvers
  • Executes automatically

⚙️ Configuration (Optional)

// config/graphql-helper.php

return [
    'resolver_namespace' => 'App\\GraphQL\\Resolvers',
];

📁 Folder Structure

app/
└── GraphQL/
    └── Resolvers/
        └── CreateUserResolver.php

🔌 Works With

  • Lighthouse GraphQL
  • Custom GraphQL implementations

🎯 Philosophy

  • Keep it minimal
  • Follow Laravel conventions
  • Improve developer experience
  • Avoid unnecessary abstraction

🤝 Contributing

PRs are welcome! Keep it simple and aligned with Laravel philosophy & Xiaroo Team.

📄 License

MIT

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固