📣 GraphQLConf 2024 • Sept 10-12 • San Francisco • Check out the Schedule & Get Your Ticket • Read more

Code Using GraphQL

Sort by:
API Platform
API Platform is a fully-featured, flexible and extensible API framework built on top of Symfony.
Last release 2 months ago9kMIT License
README

The following class is enough to create both a Relay-compatible GraphQL server and a hypermedia API supporting modern REST formats (JSON-LD, JSONAPI…):

<?php
 
namespace AppEntity;
 
use ApiPlatformCoreAnnotationApiResource;
use DoctrineORMMapping as ORM;
 
/**
 * Greet someone!
 *
 * @ApiResource
 * @ORMEntity
 */
class Greeting
{
    /**
     * @ORMId
     * @ORMColumn(type="guid")
     */
    public $id;
 
    /**
     * @var string Your nice message
     *
     * @ORMColumn
     */
    public $hello;
}

Other API Platform features include data validation, authentication, authorization, deprecations, cache and GraphiQL integration.

graphql-php
A PHP port of GraphQL reference implementation
Last release 2 weeks ago5kMIT License
WPGraphQL
A free, open-source WordPress plugin that provides an extendable GraphQL schema and API for any WordPress site
Last release 4 days ago4kGNU General Public License v3.0
Lighthouse
A GraphQL server for Laravel
Last release 4 days ago3kMIT License
Siler
Siler is a PHP library powered with high-level abstractions to work with GraphQL.
Last release 3 years ago1kMIT License
README

To run a Siler hello world script:

type Query {
  hello: String
}
<?php
declare(strict_types=1);
require_once '/path/to/vendor/autoload.php';
 
use SilerDiactoros;
use SilerGraphql;
use SilerHttp;
 
$typeDefs = file_get_contents(__DIR__.'/schema.graphql');
$resolvers = [
    'Query' => [
        'hello' => 'world',
    ],
];
$schema = Graphqlschema($typeDefs, $resolvers);
 
echo "Server running at http://127.0.0.1:8080";
 
Httpserver(Graphqlpsr7($schema), function (Throwable $err) {
    var_dump($err);
    return Diactorosjson([
        'error'   => true,
        'message' => $err->getMessage(),
    ]);
})()->run();

It also provides functionality for the construction of a WebSocket Subscriptions Server based on how Apollo works.

GraphQLBundle
A GraphQL server for Symfony
Last release 1 week ago1kMIT License
GraphQLite
GraphQLite is a library that offers an annotations-based syntax for GraphQL schema definition.
Last release 6 months ago1kMIT License
README

It is framework agnostic with bindings available for Symfony and Laravel. This code declares a “product” query and a “Product” Type:

class ProductController
{
    /**
     * @Query()
     */
    public function product(string $id): Product
    {
        // Some code that looks for a product and returns it.
    }
}
 
/**
 * @Type()
 */
class Product
{
    /**
     * @Field()
     */
    public function getName(): string
    {
        return $this->name;
    }
    // ...
}

Other GraphQLite features include validation, security, error handling, loading via data-loader pattern…

Railt
A PHP GraphQL Framework.
Last release 5 years ago359MIT License
Gato GraphQL
Interact with all your data in WordPress
Last release 2 weeks ago356GNU General Public License v2.0
graphql-relay-php
A library to help construct a graphql-php server supporting react-relay.
Last release 3 years ago272BSD 3-Clause "New" or "Revised" License
GraPHPinator
A GraphQL implementation for modern PHP. Includes features from latest draft, middleware directives and modules with extra functionality.
Last release 3 weeks ago40MIT License
README

GraPHPinator is feature complete PHP implementation of GraphQL server. Its job is transformation of query string into resolved Json result for a given Schema.

  • Aims to be compliant with the latest draft of GraphQL specification.
  • Fully typesafe, and therefore minimum required PHP version is 8.0. Sacrafices a tiny bit of convenience for huge amount of clarity and safety - no random configuration arrays, no mixed types, no variable function arguments - this library doesnt try to save you from verbosity, but makes sure you always know what you’ve got.
  • Code first.
  • Flexible. Easy to extend with extra functionality using Modules or middleware Directives.
  • Includes some opt-in extensions which are out of scope of official specs:
  • Project is composed from multiple smaller packages, which may be used standalone:
    • Tokenizer - Lexical analyzer of GraphQL document.
    • Parser - Syntactic analyzer of GraphQL document.
serge
Use GraphQL to define your Domain Model for CQRS/ES and let serge generate code to handle GraphQL requests.
5GNU General Public License v3.0