PHPackages                             cordero-digital/gql-query-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. cordero-digital/gql-query-loader

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

cordero-digital/gql-query-loader
================================

A PHP library that adds native .gql and .graphql file type support.

v1.3.0(12mo ago)16MITPHPPHP &gt;=8.1

Since Feb 6Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/Cordero-Digital/GQL-Query-Loader)[ Packagist](https://packagist.org/packages/cordero-digital/gql-query-loader)[ RSS](/packages/cordero-digital-gql-query-loader/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (6)Used By (0)

GQL Query Loader
================

[](#gql-query-loader)

A simple library that adds support for `.gql` and `.graphql` files in your PHP application.

Features
--------

[](#features)

- Load GraphQL queries from `.graphql` and `.gql` files.
- Supports variable replacement within queries.
- Includes fragment files via `#include "fragment.graphql"` syntax.
- Prevents duplicate fragment loading.

Requirements
------------

[](#requirements)

- PHP &gt;=8.1

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

[](#installation)

### Install with composer

[](#install-with-composer)

```
$  composer  require  cordero-digital/gql-query-loader
```

### Install without composer

[](#install-without-composer)

1. Download the latest [release](https://github.com/Cordero-Digital/GQL-Query-Loader/releases)
2. Extract the `.zip` or `.tar.gz` to your machine
3. Copy `/src/Loader.php` file into your project
4. Include the `Loader.php` file into the PHP file you need the library into

```
require_once __DIR__ . '/src/Loader.php';

use CorderoDigital\GQLQueryLoader\Loader;
$loader = new Loader;
```

Usage
-----

[](#usage)

This package supports fragments. The package assumes the fragments are located in a sub directory called `/fragments` located next to the query.

### Variable replacement

[](#variable-replacement)

This package supports passing PHP values into Graphql files by doing string replacement. This allows you to hardcode your PHP variables into the compiled Graphql query. A couple things to note:

You pass the variables in to the `loadQuery()` method where the key is the variable name in the Graphql file. Ex:

```
// Your PHP file
$query = (new  Loader)->loadQuery($this->root  .  'queries/variableNotInArrayExceptionTest.gql', ['id' => 123])->query();
```

```
# Your graphql file
query {
	user{{ id }} {
		id
		name
	}
}
```

```
# result
query {
	user(id: 123) {
		id
		name
	}
}
```

If you want multiple hard coded variables on a single object you would do:

```
// your PHP file
$query = (new  Loader)->loadQuery($this->root  .  'queries/variableNotInArrayExceptionTest.gql', ['id' => 123, 'status' => 'active'])->query();
```

```
# Your graphql file
query {
	user{{ id, status }} {
		id
		name
	}
}
```

```
# result
query {
	user(id: 123, status: "active") {
		id
		name
	}
}
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance50

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Total

5

Last Release

364d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/cordero-digital-gql-query-loader/health.svg)

```
[![Health](https://phpackages.com/badges/cordero-digital-gql-query-loader/health.svg)](https://phpackages.com/packages/cordero-digital-gql-query-loader)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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