PHPackages                             unclecheese/silverstripe-graphql-forms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. unclecheese/silverstripe-graphql-forms

ActiveSilverstripe-vendormodule[API Development](/categories/api)

unclecheese/silverstripe-graphql-forms
======================================

A POC for SilverStripe forms in graphql.

1.x-dev(6y ago)02301[2 issues](https://github.com/unclecheese/silverstripe-graphql-forms/issues)1BSD-3-ClausePHPCI failing

Since Oct 20Pushed 5y ago2 watchersCompare

[ Source](https://github.com/unclecheese/silverstripe-graphql-forms)[ Packagist](https://packagist.org/packages/unclecheese/silverstripe-graphql-forms)[ RSS](/packages/unclecheese-silverstripe-graphql-forms/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (2)Used By (1)

SilverStripe graphql forms (POC)
================================

[](#silverstripe-graphql-forms-poc)

Really simple implementation of `FormSchema` in graphql.

Installation
------------

[](#installation)

`$ composer require unclecheese/silverstripe-graphql-forms:dev-master`

Usage
-----

[](#usage)

### Register your forms in your schema config

[](#register-your-forms-in-your-schema-config)

\*app/\_graphql/config.yml

```
registeredForms:
  - 'MyProject\Pages\ContactPageController.ContactForm'

```

In this example, the key `ContactForm` is the name of the form you will pass as an argument to the `Form` query in graphql (it's an enum).

The value can take on a number of different implementations. Here, `'MyProject\Pages\ContactPageController.ContactForm'` refers to:

*ContactPageController.php*

```
namespace MyProject\Pages;

class ContactPageController extends Controller
{
    public function ContactForm()
    {
        // return Form instance
    }
}
```

You can also use a fully-qualified `Form` subclass:

```
ContactForm: 'MyProject\Forms\ContactForm'

```

You can also map it to a method on a `FormFactoryInterface` that is registered with the query creator (see below).

```
ContactForm: 'myMethod'

```

### Usage with Userforms

[](#usage-with-userforms)

If you're using `silverstripe/userforms` to generate forms in the CMS, there is a specialised form factory bundled with this module to allow you to register these. Because they all share the same controller class, you can instead refer to these forms by their link or ID.

```
MyCMSForm: 'who-we-are/contact-us'

```

Or, you can use an ID

```
MyCMSForm: 45

```

### Form factories

[](#form-factories)

By default, the forms are generated using the naming conventions above due to the `DefaultFormFactory`being registered in the `FormQueryCreator`. Its `getFormByName` function resolves the mapping to an actual `Form` object.

If you have custom ways of generating forms, simply register a new factory.

```
class MyFormFactory implements FormFactoryInterface
{
  public function getFormByName(string $name): ?Form
  {
    // Get a Form based on $name
  }
}
```

Additionally, to map methods directly to forms, you can subclass `DefaultFormFactory`.

```
class MyDefaultFormFactory extends DefaultFormFactory
{
  public function MyForm()
  {
    // return instance of MyForm. The parent getFormByName() function checks if
    // this method is defined before advancing through any other logic.
  }
}
```

Don't forget to register your form factories!

```
SilverStripe\Core\Injector\Injector:
  UncleCheese\GraphQLForms\FormFactoryRegistry:
    properties:
      factories:
        myFactory: '%$MyProject\MyFormFactory'

```

Querying
--------

[](#querying)

```
query {
  form(name: MyForm) {
    schema {
      fields {
        id
        name
        type
        title
        # Recursive, for composite fields
        children {
          name
          type
          title
        }
      }
      actions {
        name
        title
      }
    }
  }
}

```

Caveats
-------

[](#caveats)

- Methods that generate forms **must be deterministic!** No hiding and showing fields based on state (at least not yet).
- If you're using an explicit instance of a `Form` subclass, it needs to be instantiable through `singleton()`. Ensure that any required constructor params are auto-injected.
- Doesn't do anything fancy like composite fields
- TODO: mutations, form submissions
- File uploads? Stop.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2393d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/654636?v=4)[Aaron Carlino](/maintainers/unclecheese)[@unclecheese](https://github.com/unclecheese)

---

Tags

silverstripecms

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/unclecheese-silverstripe-graphql-forms/health.svg)

```
[![Health](https://phpackages.com/badges/unclecheese-silverstripe-graphql-forms/health.svg)](https://phpackages.com/packages/unclecheese-silverstripe-graphql-forms)
```

###  Alternatives

[silverstripe/cms

The SilverStripe Content Management System

5163.4M1.3k](/packages/silverstripe-cms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
