xakepehok/array-graphql

This library can convert php arrays to GraphQL fields query

Maintainers

👁 XAKEPEHOK

Package info

github.com/XAKEPEHOK/ArrayGraphQL

pkg:composer/xakepehok/array-graphql

Statistics

Installs: 168 431

Dependents: 3

Suggesters: 0

Stars: 3

Open Issues: 0

0.0.1 2019-07-30 11:29 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause 818f207af73ef18b4f1aa575e0ecab60a6e9a270

  • Timur Kasumov aka XAKEPEHOK <icq-475204.woop@ya.ru>

arrayqueryfieldgraphql

This package is auto-updated.

Last update: 2026-06-29 01:52:05 UTC


README

This library can convert php arrays to GraphQL fields query. It can remove duplicate fields and can thrown exceptions about incorrect array data

Installation

composer require xakepehok/array-graphql

Usage

<?php
$fields = [
 'id',
 'id',
 'registeredAt',
 'name' => [
 'firstName',
 'firstName',
 'middleName',
 'lastName',
 ],
 'history' => [
 'count',
 'count',
 'records' => [
 'id',
 'name' => [
 'firstName',
 'middleName',
 'lastName',
 ],
 ]
 ],
];

echo \XAKEPEHOK\ArrayGraphQL\ArrayGraphQL::convert($fields);

will print something like

{
 id,
 registeredAt,
 name {
 firstName,
 middleName,
 lastName
 },
 history {
 count,
 records {
 id,
 name {
 firstName,
 middleName,
 lastName
 }
 }
 }
}