承接 phpnomad/webonyx-integration 相关项目开发

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

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

phpnomad/webonyx-integration

Composer 安装命令:

composer require phpnomad/webonyx-integration

包简介

webonyx/graphql-php integration for the PHPNomad GraphQL layer

README 文档

README

Latest Version Total Downloads PHP Version License

Integrates webonyx/graphql-php with PHPNomad's GraphQL layer. Provides the concrete GraphQLStrategy that phpnomad/graphql declares as an abstraction, so applications can serve GraphQL queries through the webonyx engine without binding their resolvers to it.

Installation

composer require phpnomad/webonyx-integration

What This Provides

  • WebonyxGraphQLStrategy implements GraphQLStrategy from phpnomad/graphql. It stitches together SDL fragments and resolver maps contributed by registered TypeDefinitions, builds one webonyx Schema, and executes queries through GraphQL::executeQuery().
  • Resolver classes are resolved out of a phpnomad/di InstanceProvider, so a FieldResolver can depend on datastores, services, or any other bound class through normal constructor injection. The schema is built lazily on the first execute() call and rebuilt when a new type definition is registered.

Requirements

  • PHP 8.2+
  • phpnomad/graphql
  • phpnomad/di
  • webonyx/graphql-php ^15.0

Usage

Bind WebonyxGraphQLStrategy to the GraphQLStrategy interface in your container, then register a TypeDefinition for each slice of your schema.

<?php

use PHPNomad\GraphQL\Interfaces\FieldResolver;
use PHPNomad\GraphQL\Interfaces\GraphQLStrategy;
use PHPNomad\GraphQL\Interfaces\ResolverContext;
use PHPNomad\GraphQL\Interfaces\TypeDefinition;
use PHPNomad\GraphQL\Webonyx\Strategies\WebonyxGraphQLStrategy;

$container->bind(GraphQLStrategy::class, WebonyxGraphQLStrategy::class);

class PostSchema implements TypeDefinition
{
    public function getSdl(): string
    {
        return <<<SDL
            type Post { id: ID! title: String! }
            extend type Query { posts: [Post!]! }
        SDL;
    }

    public function getResolvers(): array
    {
        return [
            'Query' => ['posts' => PostsQueryResolver::class],
        ];
    }
}

class PostsQueryResolver implements FieldResolver
{
    public function __construct(private readonly PostRepository $posts)
    {
    }

    public function resolve(mixed $rootValue, array $args, ResolverContext $context): mixed
    {
        return $this->posts->all();
    }
}

$strategy = $container->get(GraphQLStrategy::class);
$strategy->registerTypeDefinition(fn() => new PostSchema());

/** @var ResolverContext $context */
$result = $strategy->execute('{ posts { id title } }', [], $context);

Because resolvers are referenced by class name and instantiated through the container, their constructor dependencies wire through the same DI bindings as the rest of the application.

Documentation

Framework docs live at phpnomad.com. For the underlying engine, see the webonyx/graphql-php repository and its schema and resolver reference.

License

MIT. See LICENSE.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固