From ff848e14c5dadf438aee864e6992b6d2de3b2a8c Mon Sep 17 00:00:00 2001 From: Sam Hibberd Date: Wed, 13 Jul 2022 23:11:01 +0100 Subject: [PATCH] GQL Type Updates + Readme --- README.md | 17 +++++++++++++++++ src/gql/types/LinkType.php | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/README.md b/README.md index cb48b29..ab66c62 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,23 @@ would output `Visit Profile` which is the defaul {{ entry.linkItField.user }} +**GraphQL** + +Linkit supports querying subfields with GraphQl, the following fields are available: + + myLinkitField { + label + type + typeHandle + available + link + url + text + target + element + } + +Take a look at the Craft GraphQL explorer to have a play with the return values. **A Note On Element Status** diff --git a/src/gql/types/LinkType.php b/src/gql/types/LinkType.php index 3510cf7..a252cd3 100644 --- a/src/gql/types/LinkType.php +++ b/src/gql/types/LinkType.php @@ -43,6 +43,13 @@ public static function getFieldDefinitions(): array 'name' => 'typeHandle', 'type' => Type::string(), ], + 'available' => [ + 'name' => 'available', + 'type' => Type::boolean(), + 'resolve' => function($source, $arguments) { + return $source->isAvailable(); + }, + ], 'link' => [ 'name' => 'link', 'type' => Type::string(),