# 0313-functions-register-graphql-field

<!--
This file is auto-generated by scripts/functions/generate-function-docs.js.
Do not edit manually.
-->
---
title: register_graphql_field
docType: function
plugin: wp-graphql
---

# register_graphql_field

```php
register_graphql_field( string $type_name, string $field_name, array $config ): void;
```

Given a Type Name, Field Name, and a $config array, this adds a Field to a registered Type in the TypeRegistry

- **Since:** 0.1.0
- **Source File:** `plugins/wp-graphql/access-functions.php`

## Parameters

- `$type_name` (`string`): The name of the Type to add the field to
- `$field_name` (`string`): The name of the Field to add to the Type
- `$config` (`array<string,mixed>`): The Type config

## Throws

- `\Exception`

## Recipes

- [Add Edit Link to All Post Types](/recipes/add-edit-link-to-all-post-types)
- [Add field for unencoded content](/recipes/add-field-for-unencoded-content)
- [Add field to output URLs for Sitemap](/recipes/add-field-to-output-urls-for-sitemap)
- [Add WP Admin Color Schemes to WPGraphQL](/recipes/add-wp-admin-color-schemes-to-wpgraphql)
- [List of Key Values](/recipes/list-of-key-values)
- [Popular Posts](/recipes/popular-posts)
- [Register field as a list of strings](/recipes/register-field-as-a-list-of-strings)
- [Register GraphQL Field with Argument](/recipes/register-graphql-field-with-argument)
- [Register object and field for custom list of users](/recipes/register-object-and-field-for-custom-list-of-users)

## Source

- [`plugins/wp-graphql/access-functions.php:332`](https://github.com/wp-graphql/wp-graphql/blob/main/plugins/wp-graphql/access-functions.php#L332)

```php
function register_graphql_field( string $type_name, string $field_name, array $config ): void {
```