Forest header image

Symfony Finland
Random things on PHP, Symfony and web development

Import the Facebook GraphQL example data model to eZ Platform

GraphQL is an interesting technology open sourced by Facebook. Thanks to the PHP and Symfony communities, there is already a lot of work done for devs to use GraphQL in Symfony applications.

eZ Platform being an application built on the full stack Symfony Framework, this applies to eZ developers as well. One of the things that eZ Platform adds on top of Symfony is obviously the feature complete content repository. Using this together with GraphQL will require some additional glue code, which we will need to take a look at in the future.

At this point we will start off with importing a partial data model describing the Star Wars universe widely used in the GraphQL examples. To import the created datamodel, first install the Kaliop Migrations Bundle and enable it.

Next up is cloning the bundle containing the exports: GraphQLStarwarsEzPlatformBundle

After enabling the bundle in your appkernel you can execute the migrations using the console:

 php app/console kaliop:migration:update

Once this is done, then your eZ Platform installation will now contain the following content types with specified content structures:

  • Droid
    • ID (string)
    • Name (string)
    • Friends (object relations)
    • Appears in (object relations)
    • Primary function (string)
  • Human
    • ID (string)
    • Name (string)
    • Home planet (string)
    • Friends (object relations)
    • Appears in (object relations)

in addition there are some content objects as well:

  • Droids
    • Artoo
    • Threepio
  • Humans
    • Luke Skywalker
    • Darth Vader
    • Han Solo
    • Leia Organa
    • Wilhuff Tarkin

This bundle does not expose a GraphQL interface to the created data, but just contains the data structure itself. This can be implemented in the future using the groundwork available for Symfony and GraphQL.


Written by Jani Tarvainen on Sunday May 29, 2016
Permalink - Tags: ezplatform, symfony, graphql

« Introducing the Kaliop Migrations Bundle for eZ Platform and eZ Publish - How to use Composer packages directly from GitHub (or other VCS) »