# STEP-4 Simple GraphQl and Resolver

[**STEP-4**](https://github.com/GAkim/SocialShareGraphQl/tree/STEP-4)

{% embed url="<https://www.youtube.com/watch?v=hIPoQ1uma2A>" %}

&#x20;In this particular ste&#x70;**,** we going to create a sample graphql shema and resolver.

1. Create **schema.graphqls** in **\<MODULE ROOT>/etc/**

{% code title="ScandiPWA/SocialShareGraphQl/etc/schema.graphqls" %}

```graphql
type Query {
   socialShare: socialShareType @resolver(class:"\\ScandiPWA\\SocialShareGraphQl\\Model\\Resolver\\SocialShare")
}

type socialShareType {
   enabled: String
}

```

{% endcode %}

&#x20;  2\. Create **Model** folder in **\<MODULE ROOT>** and **Resolver** folder in it.\
&#x20;  3\. Create **SocialShare.php** in **\<MODULE ROOT>/Model/Resolver**

{% code title="ScandiPWA/SocialShareGraphQl/Model/Resolver/SocialShare.php" %}

```php
<?php

declare(strict_types=1);

namespace ScandiPWA\SocialShareGraphQl\Model\Resolver;

use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
use Magento\Framework\GraphQl\Query\Resolver\Value;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\Framework\App\Config\ScopeConfigInterface;

/**
* @package ScandiPWA\SocialShareGraphQl\Model\Resolver
*/
class SocialShare implements ResolverInterface
{
   /**
    * @param Field $field
    * @param ContextInterface $context
    * @param ResolveInfo $info
    * @param array|null $value
    * @param array|null $args
    * @return string[]
    */
   public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
   {
       $result = [
           'enabled' => 'works'
       ];

       return $result;
   }
}

```

{% endcode %}

&#x20;  4\. run `cache:flush`

&#x20; 5\. Open GraphQl Client, for example, [**Altair GraphQL Client**](https://chrome.google.com/webstore/detail/altair-graphql-client/flnheeellpciglgpaodhkhmapeljopja/related?utm_source=chrome-ntp-icon) execute a query and check if you created       resolver is responding

![](https://lh6.googleusercontent.com/YMGG7SeRgIsYOnZE7mMhlH06EkD6umtMTZFhffRQ5J1ZeRY3YNTDznfB1FB-8UP-gL1BN2_NtSXCrWPiC4BH0JOMZ6KwkJsiipJSvuDw74CPzcNdMfam3AZqFod0BcX9meSYQzoN)

**useful materials:** [**GraphQl queries**](https://docs.scandipwa.com/structure/building-blocks-summary/constructing-graphql-queries?q=graphql)**,** [**Working with GraphQL**](https://docs.scandipwa.com/developing-with-scandi/working-with-magento/developing-the-magento-backend)<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.scandipwa.com/tutorials/scandipwa-social-share/step-4-simple-graphql-and-resolver.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
