Skip to content

Commit

Permalink
FIX: Add compatibility with graphql
Browse files Browse the repository at this point in the history
This does **not** add full graphql functionality but fixes #133
  • Loading branch information
AndrewHaine committed Oct 15, 2022
1 parent aa9a375 commit 0871f2c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Blueprints/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Blueprint
/**
* Return an instance of a blueprint, populated with fields
*
* @return Statamic\Facades\Blueprint
* @return Statamic\Fields\Blueprint
*/
public static function requestBlueprint();
}
21 changes: 20 additions & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
namespace WithCandour\AardvarkSeo;

use Illuminate\Support\Facades\Route;
use Statamic\Facades\Git;
use Statamic\Facades\CP\Nav;
use Statamic\Facades\Git;
use Statamic\Facades\GraphQL;
use Statamic\Facades\Permission;
use Statamic\Events\EntryBlueprintFound;
use Statamic\Events\TermBlueprintFound;
use Statamic\GraphQL\Types\GridItemType;
use Statamic\Providers\AddonServiceProvider;
use WithCandour\AardvarkSeo\Blueprints\CP\OnPageSeoBlueprint;
use WithCandour\AardvarkSeo\Events\AardvarkContentDefaultsSaved;
use WithCandour\AardvarkSeo\Events\AardvarkGlobalsUpdated;
use WithCandour\AardvarkSeo\Events\Redirects\ManualRedirectCreated;
Expand Down Expand Up @@ -100,6 +103,9 @@ public function boot()

// Set up git integration
$this->bootGitListener();

// Add compatibility with GraphQL
$this->bootGraphqlCompatibility();
}

/**
Expand Down Expand Up @@ -232,4 +238,17 @@ protected function bootGitListener(): void
}
}
}

/**
* Register a custom graphql type for our localized_urls field
*
* @return void
*/
protected function bootGraphqlCompatibility()
{
if (config('statamic.graphql.enabled')) {
$blueprint = OnPageSeoBlueprint::requestBlueprint();
GraphQL::addType(new GridItemType($blueprint->field('localized_urls')->fieldtype(), 'GridItem_LocalizedUrls'));
}
}
}

0 comments on commit 0871f2c

Please sign in to comment.