Forest header image

Symfony Finland
Random things on PHP, Symfony and web development

State of GraphQL PHP libraries and Symfony integrations in 2017

GraphQL has continued to gain momentum over the course of 2017. While it's certainly not a replacement for REST in all cases, it does provide consumers of Content APIs, etc. better ergonomics than general purpose RESTful interfaces. For PHP there are currently two popular libraries, both of which have Symfony integration Bundles.

Creating a GraphQL compliant server implementation is not a trivial task and it is not advisable to create your own from scratch for any language. For PHP there are currently two libraries that offer solid base to build GraphQL implementations on top of:

Both of these libraries provide a PHP port based on the Reference GraphQL implementation written in JavaScript. Functionally neither of these options are superior, and the basic principle is the same; to offer a framework to set up types, resolving, etc. that works according to the GraphQL specification.

Both the Webonyx and Youshido libraries are being actively developed, and have a relatively large contributor number of 28 and 32 respectively. With the GraphQL specification now stable and the implementations very feature complete, there is not a lot of significant work that is being done to these libraries.

Symfony GraphQL integration Bundles

The Webonyx library and Youshido libraries also have integrations to the Symfony Framework. Like the libraries themselves, both Bundles are virtually identical in functionality; they integrate the underlying library to the framework configuration methods, access to the GraphiQL client, etc. They let developers get a headstart and start defining configurations and developing their resolvers, instead of boilerplating framework integration.

For the Youshido GraphQL integration bundle comes from the same team of developers as the library itself. The Symfony Bundle is straightforward to integrate, is well documented and comes with an example demo app implementation. It's also worth noting that the Drupal 8 GraphQL module is using the Youshido library under the hood.

The GraphQL integration Bundle for the Webonyx library is from a separate team than the library is. The integration bundle is developer by Overblog, a blogging platform from France. Like the Youshido framework, the bundle integrates the library to the framework. The documentation has improved lately, but a demo implementation would help new developers get started faster.

Conclusion

Developers with existing or new PHP applications now have two solid options for building GraphQL implementations on top of. Both Webonyx and Youshido libraries are good options, and seem to have a stable future with widespread use.

For Symfony developers the same is true, both libraries have a high quality integration to the framework. Both options are great, but what might be a deciding factor currently is whether you are using the Symfony Standard Edition or Symfony Flex.

The Overblog integration has already started to focus on Symfony Flex, while the Youshido team has not yet taken any steps towards supporting Flex officially.

Learn more about GraphQL:


Written by Jani Tarvainen on Monday November 13, 2017
Permalink -

« Attaching React.js to a template rendered on the server with Twig - Four things I like about Symfony 4 »