Skip to content

Commit b2718c9

Browse files
authored
feat: add field type to graphql/acf schema (#64)
1 parent 99a609a commit b2718c9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

plugin.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ protected function register()
8282
return new Field($this);
8383
});
8484
}
85+
86+
if (function_exists('register_graphql_acf_field_type')) {
87+
add_action('wpgraphql/acf/registry_init', function () {
88+
register_graphql_acf_field_type($this->name, [
89+
'graphql_type' => 'string',
90+
'resolve' => function ($root, $args, $context, $info, $field_config) {
91+
$value = $field_config->resolve_field($root, $args, $context, $info);
92+
93+
if (is_null($value)) {
94+
return null;
95+
}
96+
97+
return $value['slug'];
98+
},
99+
]);
100+
});
101+
}
85102
}
86103

87104
/**

0 commit comments

Comments
 (0)