Mutations
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php namespace GermanAirlinesVa\Graphql\Classes;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use Nuwave\Lighthouse\Subscriptions\Subscriber;
|
||||
use Nuwave\Lighthouse\Schema\Types\GraphQLSubscription;
|
||||
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
|
||||
|
||||
class Dummy extends GraphQLSubscription
|
||||
{
|
||||
/**
|
||||
* Check if subscriber is allowed to listen to the subscription.
|
||||
*
|
||||
* @param \Nuwave\Lighthouse\Subscriptions\Subscriber $subscriber
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(Subscriber $subscriber, Request $request): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter which subscribers should receive the subscription.
|
||||
*
|
||||
* @param \Nuwave\Lighthouse\Subscriptions\Subscriber $subscriber
|
||||
* @param mixed $root
|
||||
* @return bool
|
||||
*/
|
||||
public function filter(Subscriber $subscriber, $root): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode topic name.
|
||||
*
|
||||
* @param \Nuwave\Lighthouse\Subscriptions\Subscriber $subscriber
|
||||
* @param string $fieldName
|
||||
* @return string
|
||||
*/
|
||||
public function encodeTopic(Subscriber $subscriber, string $fieldName): string
|
||||
{
|
||||
// Create a unique topic name based on the `author` argument
|
||||
return Str::snake($fieldName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode topic name.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @param \App\Post $root
|
||||
* @return string
|
||||
*/
|
||||
public function decodeTopic(string $fieldName, $root): string
|
||||
{
|
||||
return Str::snake($fieldName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the subscription.
|
||||
*
|
||||
* @param \App\Post $root
|
||||
* @param array<string, mixed> $args
|
||||
* @param \Nuwave\Lighthouse\Support\Contracts\GraphQLContext $context
|
||||
* @param \GraphQL\Type\Definition\ResolveInfo $resolveInfo
|
||||
* @return mixed
|
||||
*/
|
||||
public function resolve($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo): array
|
||||
{
|
||||
return array($root);
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class SchemaSourceProvider implements LighthouseSchemaSourceProvider
|
||||
public function getSchemaString(): string
|
||||
{
|
||||
// root types
|
||||
$schema = '
|
||||
$schema = "
|
||||
type Query {
|
||||
dummy: Boolean
|
||||
}
|
||||
@@ -76,7 +76,11 @@ class SchemaSourceProvider implements LighthouseSchemaSourceProvider
|
||||
type Mutation {
|
||||
dummy: Boolean
|
||||
}
|
||||
';
|
||||
|
||||
type Subscription {
|
||||
dummy: Boolean @subscription(class: \"GermanAirlinesVa\\\\Graphql\\\\Classes\\\\Dummy\")
|
||||
}
|
||||
";
|
||||
// schema
|
||||
$schema .= collect($this->getGraphMap())->implode('schema', '');
|
||||
return $schema;
|
||||
|
||||
Reference in New Issue
Block a user