PHPackages                             mathsgod/graphql-php-loader - 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. mathsgod/graphql-php-loader

ActiveLibrary[API Development](/categories/api)

mathsgod/graphql-php-loader
===========================

A php loader for webonyx graphql

1.0.0(5y ago)08MITPHP

Since Feb 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/mathsgod/graphql-php-loader)[ Packagist](https://packagist.org/packages/mathsgod/graphql-php-loader)[ RSS](/packages/mathsgod-graphql-php-loader/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

[![PHP Composer](https://github.com/mathsgod/graphql-php-loader/actions/workflows/php.yml/badge.svg?branch=main)](https://github.com/mathsgod/graphql-php-loader/actions/workflows/php.yml)

graphql-php-loader
==================

[](#graphql-php-loader)

A simple loader to generate Schema for webonyx/graphql-php

Usage
-----

[](#usage)

Use file structure to create and design graphql schema.

1. Create a folder "graphql" at your document root.
2. Create a folder "Query" in "graphql" folder.
3. Now you can create field for Query

### Init

[](#init)

```
use GraphQL\Loader;
use GraphQL\Type\Schema;

$loader=new Loader();

$config = SchemaConfig::create()
    ->setQuery($loader->queryType())
    ->setMutation($loader->mutationType());

$schema = new Schema($config);
```

### Example

[](#example)

#### Simple query

[](#simple-query)

Create a file hello.php in "graphql/Query" folder

```
graphql
+-- Query
|  +-- hello.php

```

Query/hello.php

```
return [
    "type"=>"String",
    "resolve"=>function($root,$args,$context){
        return "world!";
    }
];
```

It equivalent to build to following schema

```
type Query{
    hello:String
}
```

#### Custom type

[](#custom-type)

If you want to use custom object type, just create type file at graphql folder

```
graphql
+-- Query
|  +-- me.php
+-- User.php

```

Query/me.php

```
return [
    "type"=>"User",
    "resolve"=>function($root,$args,$context){
        return $context->me; //return object
    }
];
```

User.php

```
return [
    "fields"=>[
        "first_name"=>"String",
        "last_name"=>"String"
    ]
];
```

It equivalent to build to following schema

```
type Query{
    me:User
}

type User{
    first_name:String
    last_name:String
}
```

#### Fields of custom type

[](#fields-of-custom-type)

If you want to create custom fields for custom object type, just create folder for the custom object

##### example

[](#example-1)

User has multiple phone number

graphql/User.php

```
return [
    "fields"=>[
        "first_name"=>"String",
        "last_name"=>"String"
    ]
];
/*
no need create phone in fields,
by create file phone.php in User folder, it auto generate fields in User type
*/
```

create phone.php in folder "User"

graphql/User/phone.php

```
return [
    "type"=>"[String]",
    "resolve"=>function($user,$args,$context){
        return $user->getPhones(); //return multi phone
    }
];
```

```
graphql
+-- Query
|  +-- me.php
+-- User
|  +-- phone.php
+-- User.php

```

It equivalent to build to following schema

```
type Query{
    me:User
}

type User{
    first_name:String
    last_name:String
    phone:[String]
}
```

### Sub folder structure

[](#sub-folder-structure)

```
graphql
+-- Query
|  +-- User
|      +-- list.php
|  +-- Invoice
|      +-- list.php
+-- User.php
+-- Invoice.php

```

now you can query by following

```
query{
    User{
        list{
            first_name
            last_name
        }
    }
    Invoice{
        list{
            invoice_no
        }
    }
}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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 ~7 days

Total

3

Last Release

1895d ago

Major Versions

0.2.0 → 1.0.02021-03-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18732337?v=4)[Raymond](/maintainers/mathsgod)[@mathsgod](https://github.com/mathsgod)

---

Top Contributors

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

---

Tags

graphqlphp

### Embed Badge

![Health badge](/badges/mathsgod-graphql-php-loader/health.svg)

```
[![Health](https://phpackages.com/badges/mathsgod-graphql-php-loader/health.svg)](https://phpackages.com/packages/mathsgod-graphql-php-loader)
```

###  Alternatives

[nuwave/lighthouse

A framework for serving GraphQL from Laravel

3.5k10.7M93](/packages/nuwave-lighthouse)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[wp-graphql/wp-graphql

GraphQL API for WordPress

3.8k391.7k19](/packages/wp-graphql-wp-graphql)[overblog/graphql-bundle

This bundle provides tools to build a GraphQL server in your Symfony App.

8027.9M28](/packages/overblog-graphql-bundle)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[aimeos/ai-admin-graphql

Aimeos Admin GraphQL API extension

944100.0k4](/packages/aimeos-ai-admin-graphql)

PHPackages © 2026

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