PHPackages                             99designs/graphql - 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. 99designs/graphql

ActiveLibrary[API Development](/categories/api)

99designs/graphql
=================

Pure PHP GraphQL

v1.0.1(2y ago)04.6k1[1 PRs](https://github.com/99designs/GraphQL-php/pulls)1MITPHPPHP &gt;=5.5

Since Aug 15Pushed 1y agoCompare

[ Source](https://github.com/99designs/GraphQL-php)[ Packagist](https://packagist.org/packages/99designs/graphql)[ RSS](/packages/99designs-graphql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (1)

Looking for Maintainers!
========================

[](#looking-for-maintainers)

Unfortunatelly, we cannot longer support this package and are looking for someone to take the ownership. Currently Only PRs with bugfixes and not breaking BC are being merged. It's very sad to acknowledge this, but we hope that someone can take it further with the community.

Please, PM @viniychuk if you are interested in taking over.

GraphQL
=======

[](#graphql)

[![Join the chat at https://gitter.im/Youshido/GraphQL](https://camo.githubusercontent.com/6bc9773284523f7a8a63051dfa34cf1c989312cc387c2544379ffd1224439e71/68747470733a2f2f6261646765732e6769747465722e696d2f596f75736869646f2f4772617068514c2e737667)](https://gitter.im/Youshido/GraphQL?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[![Latest Stable Version](https://camo.githubusercontent.com/f121910844b71556dac21f32e59df3f24617184bd30c1a9a7fce373aae85a5c4/68747470733a2f2f706f7365722e707567782e6f72672f796f75736869646f2f6772617068716c2f762f737461626c65)](https://packagist.org/packages/youshido/graphql)[![Build Status](https://camo.githubusercontent.com/b232472ccb631ef1e4a388b773254259cb5d90995ce80792932313360cf937cc/68747470733a2f2f7472617669732d63692e6f72672f796f75736869646f2d7068702f4772617068514c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/youshido-php/GraphQL)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f968e8c4f546225d0480dfb61372577b7d6d692c7d9f3d49d15a61802a09c1b4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f596f75736869646f2f4772617068514c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Youshido/GraphQL/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/9a97f42a2d0fc541e3a3f500a58591b4267ce39c34e3845e38a81de32e797483/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f596f75736869646f2f4772617068514c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Youshido/GraphQL/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/2f66439d21f6e028fae201b141e2d169c3ba0e4c34ab8ddfc3ec9fb866b46746/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f38623861623261322d333266622d343239382d613938362d6237356361353233633763392f6d696e692e706e67)](https://insight.sensiolabs.com/projects/8b8ab2a2-32fb-4298-a986-b75ca523c7c9)

This is a pure PHP realization of the GraphQL protocol based on the working draft of the official GraphQL Specification located on .

GraphQL is a query language for APIs. It brings a new paradigm to the world of client-server communication and delivers a much more predictable behavior and smallest possible over-the-wire responses to any request. GraphQL advanced in many ways and has fundamental quality improvements:

- strongly typed communication protocol makes both client and server predictable and more stable
- encourages you to build a constantly evolving APIs and not use versions in the endpoints
- bulk requests and responses to avoiding waiting for multiple HTTP handshakes
- easily generated documentation and incredibly intuitive way to explore created API
- clients will be much less likely to require backend changes

> Current package is and will be trying to be kept up to date with the latest revision of the official GraphQL Specification which is now of April 2016.

> Symfony bundle is available by the link –

> If you have any questions or suggestions – let's talk on [GraphQL Gitter channel](https://gitter.im/Youshido/GraphQL)

Table of Contents
-----------------

[](#table-of-contents)

- [Getting Started](#getting-started)
- [Installation](#installation)
- [Example – Creating Blog Schema](#tutorial--creating-blog-schema)
    - [Inline approach](#inline-approach)
    - [Object Oriented approach](#object-oriented-approach)
    - [Choosing approach for your project](#choosing-approach-for-your-project)
- [Query Documents](#query-documents)
- [Type System](#type-system)
    - [Scalar Types](#scalar-types)
    - [Objects](#objects)
    - [Interfaces](#interfaces)
    - [Enums](#enums)
    - [Unions](#unions)
    - [Lists](#lists)
    - [Input Objects](#input-objects)
    - [Non-Null](#non-null)
- [Building your schema](#building-your-schema)
    - [Abstract type classes](#abstract-type-classes)
    - [Mutation helper class](#mutation-helper-class)
- [Useful information](#useful-information)
    - [GraphiQL tool](#graphiql-tool)

Getting Started
---------------

[](#getting-started)

You should be better off starting with some examples and "Star Wars" become a somewhat "Hello world" for the GraphQL implementations. If you're looking just for that – you can get it via this link – [Star Wars example](https://github.com/Youshido/GraphQL/tree/master/Tests/StarWars). On the other hand, we prepared a step-by-step guide for those who wants to get up to speed bit by bit.

### Installation

[](#installation)

Install GraphQL package using composer. If you're not familiar with it, you should check out their [manual](https://getcomposer.org/doc/00-intro.md). Run `composer require youshido/graphql`.

Alternatively you can run the following commands:

```
mkdir graphql-test && cd graphql-test
composer init -n
composer require youshido/graphql
```

Now you're ready to create your `GraphQL Schema` and check if everything works fine. Your first GraphQL app will be able to receive `currentTime` request and response with a formatted time string.

> you can find this example in the examples directory – [01\_sandbox](https://github.com/Youshido/GraphQL/tree/master/examples/01_sandbox).

Create an `index.php` file with the following content:

```
