PHPackages                             segbedji/graphql-typed - 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. segbedji/graphql-typed

ActiveStatamic-addon[API Development](/categories/api)

segbedji/graphql-typed
======================

A Statamic addon that adds type-safe GraphQL arguments for collections, filters, and enums.

v0.3.0(1mo ago)096↓83.3%MITPHP

Since Mar 23Pushed 1mo agoCompare

[ Source](https://github.com/JustinyAhin/statamic-graphql-typed)[ Packagist](https://packagist.org/packages/segbedji/graphql-typed)[ RSS](/packages/segbedji-graphql-typed/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

GraphQL Typed
=============

[](#graphql-typed)

A Statamic addon that adds type-safe GraphQL arguments for better developer experience when using typed GraphQL clients.

The Problem
-----------

[](#the-problem)

Statamic's default GraphQL schema uses `String` for collection names and `JsonArgument` for filters:

```
entries(collection: [String], filter: JsonArgument, ...): EntryInterfacePagination
```

This means GraphQL clients like gqty, graphql-codegen, or Apollo can't provide autocomplete or type checking for these arguments.

The Solution
------------

[](#the-solution)

This addon replaces the `collection` argument with a dynamically generated `CollectionName` enum based on your actual collections:

```
enum CollectionName {
  ARTICLES
  PAGES
  # ... auto-generated from your collections
}

entries(collection: [CollectionName], ...): EntryInterfacePagination
```

Features
--------

[](#features)

- Dynamically generates `CollectionName` enum from your Statamic collections
- Overrides the default `entry` and `entries` queries to use the typed enum
- Generates per-field enums for select, radio, and button group fields from their blueprint options
- Zero configuration required - just install and regenerate your client types

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

[](#installation)

```
composer require segbedji/graphql-typed
```

Usage
-----

[](#usage)

After installing, regenerate your GraphQL client types. The `collection` argument will now be typed as `CollectionName` enum instead of `String`.

### Before (untyped)

[](#before-untyped)

```
query.entries({ collection: ['articles'] }) // 'articles' is just a string, no validation
```

### After (typed)

[](#after-typed)

```
query.entries({ collection: [CollectionName.ARTICLES] }) // Type-safe enum value
```

Select Field Enums
------------------

[](#select-field-enums)

Statamic types every select, radio, and button group field as a generic `LabeledValue` whose `value` is a plain `String`. This addon replaces each of those fields with a per-field type whose `value` is an enum generated from the blueprint options:

```
enum Updates_Update_TagEnum {
  NEW
  IMPROVEMENT
  FIX
  FREE_TOOL
}

type Updates_Update_TagLabeledValue {
  value: Updates_Update_TagEnum
  label: String
}
```

Typed clients then infer the option union, so `entry.tag.value` is `'NEW' | 'IMPROVEMENT' | 'FIX' | 'FREE_TOOL'` instead of `string`. Note that GraphQL serializes enum output as the enum *name* (`FREE_TOOL`), not the raw option value (`free-tool`).

Fields are left untouched (keeping the generic `LabeledValue`) when they can't be represented as an enum: `cast_booleans` selects, fields without options, and options whose sanitized names collide (e.g. `free-tool` and `free_tool`).

How It Works
------------

[](#how-it-works)

The addon registers:

1. **CollectionNameEnum** - A GraphQL enum type that dynamically generates values from `Collection::all()`
2. **TypedEntryQuery** - Extends the default `EntryQuery` but uses the `CollectionName` enum for the `collection` argument
3. **TypedEntriesQuery** - Extends the default `EntriesQuery` but uses the `CollectionName` enum for the `collection` argument
4. **SelectFieldTypeGenerator** - Walks every GraphQL-enabled collection's blueprints and overrides select-like fields with per-field enum types

Future Improvements
-------------------

[](#future-improvements)

- Add typed sort options based on available fields
- Typed enums for select fields nested inside Bard, Replicator, and Grid sets

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance89

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Every ~39 days

Total

3

Last Release

58d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dc22b1c2969a26eea741d81a9770543099b80a29200627da9861cce5fcc037c0?d=identicon)[iamsegbedji](/maintainers/iamsegbedji)

---

Top Contributors

[![JustinyAhin](https://avatars.githubusercontent.com/u/33403964?v=4)](https://github.com/JustinyAhin "JustinyAhin (4 commits)")

---

Tags

enumgraphqlfiltersstatamictyped

### Embed Badge

![Health badge](/badges/segbedji-graphql-typed/health.svg)

```
[![Health](https://phpackages.com/badges/segbedji-graphql-typed/health.svg)](https://phpackages.com/packages/segbedji-graphql-typed)
```

###  Alternatives

[statamic/statamic

Statamic

830182.1k](/packages/statamic-statamic)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

137236.2k8](/packages/statamic-rad-pack-runway)[statamic/seo-pro

71548.3k](/packages/statamic-seo-pro)[cboxdk/statamic-mcp

MCP (Model Context Protocol) server for Statamic CMS v6 — gives AI assistants structured access to content, blueprints, assets, and more.

3219.8k](/packages/cboxdk-statamic-mcp)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3618.3k](/packages/duncanmcclean-statamic-cargo)[aerni/advanced-seo

Comprehensive SEO addon for Statamic with flexibility in mind

1818.9k](/packages/aerni-advanced-seo)

PHPackages © 2026

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