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.
This lightweight and secure solution is ideal for:
The theme has no authentication system, anonymous access is allowed to specific GraphQL queries and mutations. The following mutations are available:
CustomPostType
and CustomField
classes for registering and managing post types and custom fields.Check the
docs/custom-post-types.md
anddocs/custom-fields.md
files for more information on registering custom post types and custom fields.
composer create-project technway/graphql-starter your-theme-name --no-dev
git clone https://github.com/technway/graphql-starter.git
/wp-content/themes/
.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"
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.
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. |
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.
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/
DirectoryThe 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/
DirectoryThe 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/
DirectoryThe 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/
DirectoryThe testing-graphql/
directory contains a .http
file for testing GraphQL queries. Refer to testing-graphql.md
for more information on testing GraphQL queries.
blog-posts.md
file for more information on get posts in different scenarios and getting or toggling likes.custom-post-types.md
file for more information on registering custom post types.custom-fields.md
file for more information on registering custom fields.This theme is licensed under the GNU General Public License v2 or later (GPL-2.0). See the LICENSE file for details.
For support and contributions, visit the Technway GitHub repository.
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.