定制 technway/graphql-starter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

technway/graphql-starter

Composer 安装命令:

composer require technway/graphql-starter

包简介

A specialized headless WordPress theme designed to function purely as a GraphQL API endpoint

README 文档

README

GraphQL Starter Logo

GraphQL Starter

The GraphQL Starter Theme is a specialized headless WordPress theme designed to function purely as a GraphQL API endpoint. It eliminates traditional frontend rendering and focuses solely on providing a clean and efficient GraphQL API interface.

WordPress PHP License

This lightweight and secure solution is ideal for:

  • Public content APIs
  • Headless frontend applications
  • Scenarios where content management is handled through the WordPress admin interface

The theme has no authentication system, anonymous access is allowed to specific GraphQL queries and mutations. The following mutations are available:

  • Comment creation
  • Post like toggling

Features

Core Capabilities

  • Headless WordPress API: Designed to serve as a GraphQL API for seamless integration with modern frontend frameworks like React, Vue, or Angular.

Custom Post Types and Fields

  • Easy-to-use CustomPostType and CustomField classes for registering and managing post types and custom fields.
  • Automatically integrates custom post types and fields into the GraphQL schema.
  • Flexible configuration options for easy customization

Check the docs/custom-post-types.md and docs/custom-fields.md files for more information on registering custom post types and custom fields.

GraphQL Capabilities

  • Read Operations Examples:

    • Query post types
    • Retrieve posts and their data
    • Access custom fields
    • Social sharing URLs for Posts
  • Write Operations Examples:

    • Create comments on posts
    • Toggle post likes
  • No authentication required for public operations (Anonymous access).

Installation

Using Composer (Recommended)

composer create-project technway/graphql-starter your-theme-name --no-dev

Manual Installation

  1. Download/Clone the theme from the Technway repository.
    git clone https://github.com/technway/graphql-starter.git
  2. Upload the theme folder to your WordPress installation directory under /wp-content/themes/.
  3. Activate the theme via the WordPress admin panel under Appearance > Themes.
  4. Install and activate the WPGraphQL plugin.

Rename Theme

Use the rename-theme.php script to rename the theme. The script updates all references across relevant files while preserving formatting.

Run the script from the root of the theme directory:

php ./scripts/rename-theme.php "Your New Theme Name"

Example:

php ./scripts/rename-theme.php "My Custom GraphQL Theme"

Theme Configuration

The theme.config.php file contains essential configuration constants that control various features of the theme. These constants determine which functionalities are enabled or disabled.

Configuration Constants

Constant Type Default Description
GRAPHQL_STARTER_ENABLE_CUSTOM_POST_TYPES boolean false Controls whether custom post types are enabled. When true, allows registration of custom post types. See docs/custom-post-types.md for details.
GRAPHQL_STARTER_ENABLE_CUSTOM_FIELDS boolean false Controls whether custom fields are enabled. When true, allows registration of custom fields. See docs/custom-fields.md for details.
GRAPHQL_STARTER_LIKE_POSTS_ENABLED boolean false Enables/disables the post likes system. When true, activates like/unlike queries and mutations. See docs/blog-posts.md for details.
GRAPHQL_STARTER_POST_PAGES_COUNT_ENABLED boolean true Controls whether total pages count is available in GraphQL queries. When true, adds 'total' field to pageInfo in post queries. Useful for pagination UI. See docs/blog-posts.md for details.
GRAPHQL_STARTER_SOCIAL_SHARE_ENABLED boolean false Controls whether social sharing URLs are available in post queries. See docs/blog-posts.md for details
GRAPHQL_STARTER_REDIRECT_FRONTEND_ENABLED boolean true Controls whether the frontend is redirected to the admin dashboard. When true, the frontend is redirected to the admin dashboard.

Example Usage

When GRAPHQL_STARTER_POST_PAGES_COUNT_ENABLED is true, you can query post pagination counts.

For detailed information about each feature. See the docs/ directory.

Directory Structure

graphql-starter/                   # Root directory of the theme
├── includes/                      # Core functionalities of the theme
│   ├── core/                      # Essential reusable components and logic
│   │   ├── classes/               # PHP classes for managing CPTs and CFs
│   │   │   ├── CustomField.php          # Class for defining custom fields
│   │   │   ├── CustomFieldRenderer.php  # Class for rendering custom fields
│   │   │   ├── CustomPostType.php       # Class for defining custom post types
│   │   ├── bootstrap/             # Initialization files for CPTs and fields
│   │   │   ├── cf-bootstrap.php   # Initializes custom fields
│   │   │   ├── cpt-bootstrap.php  # Initializes custom post types
│   │   ├── graphql/               # Files specific to GraphQL setup
│   │   │   ├── graphql-setup.php  # Configures GraphQL endpoints and settings
│   │   ├── custom-fields.php          # Registers and manages custom fields
│   │   ├── post-types.php             # Registers and manages custom post types
├── scripts/                       # Utility scripts for automation
│   ├── rename-theme.php           # Script to rename theme references
├── testing-graphql/               # GraphQL query test files for debugging
│   ├── *.http                     # HTTP files for testing GraphQL queries and mutations
│   ├── testing-graphql.md         # Documentation for testing GraphQL
├── docs/                          # Documentation files for the theme
├── functions.php                  # Main WordPress functions file
├── index.php                      # Empty index file
├── theme.config.php               # Theme configuration

includes/ Directory

The includes/ directory contains the core classes used to register custom post types (CPTs) and custom fields (CFs). These classes simplify the process of creating and managing CPTs and CFs within the theme. It also contains the custom-fields.php and post-types.php files, which are used to register custom fields and post types respectively.

core/ Directory

The core/ directory contains the reusable classes used to register custom post types (CPTs) and custom fields (CFs). These classes simplify the process of creating and managing CPTs and CFs within the theme.

docs/ Directory

The docs/ directory contains additional detailed documentation files about the theme, its architecture, and usage examples. Refer to docs/usage.md for more information on registering custom post types and custom fields.

testing-graphql/ Directory

The testing-graphql/ directory contains a .http file for testing GraphQL queries. Refer to testing-graphql.md for more information on testing GraphQL queries.

Usage

  • Read the blog-posts.md file for more information on get posts in different scenarios and getting or toggling likes.
  • Read the custom-post-types.md file for more information on registering custom post types.
  • Read the custom-fields.md file for more information on registering custom fields.

License

This theme is licensed under the GNU General Public License v2 or later (GPL-2.0). See the LICENSE file for details.

Support

For support and contributions, visit the Technway GitHub repository.

Credits

The GraphQL Starter Theme is built with ❤️ and maintained by Technway. Special thanks to the creators of WPGraphQL for their excellent plugin.

Contributions are welcome! Feel free to fork the repository and submit pull requests.

technway/graphql-starter 适用场景与选型建议

technway/graphql-starter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 6, 最近一次更新时间为 2025 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 technway/graphql-starter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 technway/graphql-starter 我们能提供哪些服务?
定制开发 / 二次开发

基于 technway/graphql-starter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2025-01-30