PHPackages                             divanteltd/pimcore-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. divanteltd/pimcore-graphql

AbandonedPimcore-bundle[API Development](/categories/api)

divanteltd/pimcore-graphql
==========================

Graphql Bundle for Pimcore 5. Adding possibility to manipulate DataObject through graphQl.

0.0.13(6y ago)319103[2 issues](https://github.com/DivanteLtd/pimcore-graphql/issues)GPL-3.0+PHPPHP &gt;=7.0CI failing

Since Nov 30Pushed 6y ago26 watchersCompare

[ Source](https://github.com/DivanteLtd/pimcore-graphql)[ Packagist](https://packagist.org/packages/divanteltd/pimcore-graphql)[ RSS](/packages/divanteltd-pimcore-graphql/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (14)Used By (0)

Pimcore GraphQl
===============

[](#pimcore-graphql)

Pimcore graphQl is a whole solution for building Your API. You can model Your data with simple, point and click/ drag and drop, interface, fill the data with Pimcore based backend, and our application will generate the whole graphQl schema for You.

**Table of Contents**

- [Pimcore GraphQl](#)
    - [Compatibility](#compatibility)
    - [Installing/Getting started](#installinggetting-started)
    - [Developing](#developing)
    - [Contributing](#contributing)
    - [Licensing](#licensing)
    - [Standards &amp; Code Quality](#standards--code-quality)
    - [About Authors](#a-nameauthorsaabout-authors)

Compatibility
-------------

[](#compatibility)

This module is compatible with Pimcore 5.1.0 and higher. It requires PHP in version 7.0 or higher.

Installing/Getting started
--------------------------

[](#installinggetting-started)

For existing Pimcore instalations just run `composer require divanteltd/pimcore-graphql`If You dont have Pimore instance, pleas use one of many docker images like [this](https://github.com/dpfaffenbauer/pimcore-docker-compose), follow the instructions, after successfull instalation ssh to container and run command from above.

On Pimcore level - You need to create rest user, and generate API key, which will be used for graphql communication.

[![](user.png)](user.png)

Set up default localisation for site, in System settings.

[![](localization.png)](localization.png)

For testing You can use tool like ChromeiQL, setup endpoint address `http://[your-host:your-port]/webservice/graphql/graph?apikey=[your-apikey]`and You are ready to go.

[![](endpoint.png)](endpoint.png)

Now You are ready to model Your data

### Create the Class Model/Definition

[](#create-the-class-modeldefinition)

Go to: Settings -&gt; Object -&gt; Classes and click the button Add Class.

[![alt text](https://camo.githubusercontent.com/70945b741ac17f731eb02950d8976901e95cf498599a4cd2fd7a401e1f1501c2/68747470733a2f2f70696d636f72652e636f6d2f646f63732f352e782f446576656c6f706d656e745f446f63756d656e746174696f6e2f696d672f50696d636f72655f456c656d656e74735f636c6173735f6164642e706e67 "Add class")](https://camo.githubusercontent.com/70945b741ac17f731eb02950d8976901e95cf498599a4cd2fd7a401e1f1501c2/68747470733a2f2f70696d636f72652e636f6d2f646f63732f352e782f446576656c6f706d656e745f446f63756d656e746174696f6e2f696d672f50696d636f72655f456c656d656e74735f636c6173735f6164642e706e67)

Now, there is a new product class/model which is a representation of your entity including the underlying database scheme as well as a generated PHP class you can use to create, update, list and delete your entities.

The product should have the following attributes: SKU, picture, name and description. Follow these steps to add them:

- Go to the edit page of the class product
- Click right on Base and select Add Layout Component -&gt; Panel - This is the main panel/container for the following product attributes
- To add attributes:
    - Click right on Panel, then Add data component -&gt; Text -&gt; Input, then change the name of the input component to sku (in the edit panel on the right side)
    - Just the same way you add the new data field for name
    - Now we're going to add a WYSIWYG attribute for the description. Again, click right, select Add data component -&gt; Text -&gt; WYSIWYG. We name it description.
    - The last attribute is for the picture. We can use on of the specialized image components in Other -&gt; Image. Name the attribute picture. If everything goes well, the new class looks like in the picture:

[![alt text](https://camo.githubusercontent.com/6db0a26fc2729c87cb3fff944b289b45d9acf80f636fcfde5ce509246bb9ac28/68747470733a2f2f70696d636f72652e636f6d2f646f63732f352e782f446576656c6f706d656e745f446f63756d656e746174696f6e2f696d672f50696d636f72655f456c656d656e74735f70726f647563745f636c6173732e706e67 "Class list")](https://camo.githubusercontent.com/6db0a26fc2729c87cb3fff944b289b45d9acf80f636fcfde5ce509246bb9ac28/68747470733a2f2f70696d636f72652e636f6d2f646f63732f352e782f446576656c6f706d656e745f446f63756d656e746174696f6e2f696d672f50696d636f72655f456c656d656e74735f70726f647563745f636c6173732e706e67)

Important: Every generated class in the Pimcore admin panel has also an accordingly PHP class with getters and setters. You can find the PHP class representation of our newly created class definition above in var/classes/DataObject/Product.php

### Add a new Object

[](#add-a-new-object)

We've just prepared a simple class for new products. Now we can use it to create objects in Pimcore.

- Open the objects section on the left and click on the right button after Home (Note that you can create also directories structure for objects).
- Choose Add object -&gt; product and fill the input with a name, for example: tshirt
- Add values for sku, name and description attributes.
- Click Save &amp; Publish

Probably, your view looks like below:

[![alt text](https://camo.githubusercontent.com/da13a1a3b5c64147d8b8f458c89e6e32626c9ff462bfc1af875883ecc1a49b71/68747470733a2f2f70696d636f72652e636f6d2f646f63732f352e782f446576656c6f706d656e745f446f63756d656e746174696f6e2f696d672f50696d636f72655f456c656d656e74735f6e65775f70726f647563742e706e67 "Product")](https://camo.githubusercontent.com/da13a1a3b5c64147d8b8f458c89e6e32626c9ff462bfc1af875883ecc1a49b71/68747470733a2f2f70696d636f72652e636f6d2f646f63732f352e782f446576656c6f706d656e745f446f63756d656e746174696f6e2f696d672f50696d636f72655f456c656d656e74735f6e65775f70726f647563742e706e67)

The last step to finish the product object is add a photo.

The one way to upload a photo is this button:

[![alt text](https://camo.githubusercontent.com/ca0cb2ff237a95ecb7b73fb0682c92b80ce276a51762b340d226d80db980ad2a/68747470733a2f2f70696d636f72652e636f6d2f646f63732f352e782f446576656c6f706d656e745f446f63756d656e746174696f6e2f696d672f50696d636f72655f456c656d656e74735f75706c6f61645f627574746f6e2e706e67 "Button")](https://camo.githubusercontent.com/ca0cb2ff237a95ecb7b73fb0682c92b80ce276a51762b340d226d80db980ad2a/68747470733a2f2f70696d636f72652e636f6d2f646f63732f352e782f446576656c6f706d656e745f446f63756d656e746174696f6e2f696d672f50696d636f72655f456c656d656e74735f75706c6f61645f627574746f6e2e706e67)

Upload image to an object or just drag file which you uploaded from Assets section.

Click Save &amp; Publish button.

That's it.

[![alt text](https://camo.githubusercontent.com/a058af14cad0daa926d396d67e9d4e1fbd7f48a4802e0042993cafb6e763301e/68747470733a2f2f70696d636f72652e636f6d2f646f63732f352e782f446576656c6f706d656e745f446f63756d656e746174696f6e2f696d672f50696d636f72655f456c656d656e74735f636f6d706c6574655f6f626a6563742e706e67 "Asset")](https://camo.githubusercontent.com/a058af14cad0daa926d396d67e9d4e1fbd7f48a4802e0042993cafb6e763301e/68747470733a2f2f70696d636f72652e636f6d2f646f63732f352e782f446576656c6f706d656e745f446f63756d656e746174696f6e2f696d672f50696d636f72655f456c656d656e74735f636f6d706c6574655f6f626a6563742e706e67)

For more detailed information please refer [here](https://pimcore.com/docs/5.x/Development_Documentation/Objects/index.html)

Quick summary [![](graphql.gif)](graphql.gif)

Developing
----------

[](#developing)

In some cases You will see this kind of output from Your graphQl query

[![](custom.png)](custom.png)

Looks like You are using custom type, in Your class. What You need to do, is to implement following interface

```
