Support Log in
All Features of Field Forge

GraphQL Schema Generation — WPGraphQL Integration

Field Forge Pro generates GraphQL Schema Definition Language (SDL) for your field groups when you press Generate GraphQL, and registers its field types with WPGraphQL when WPGraphQL is active. The custom fields can then be queried through GraphQL.

Integration scope note: Native GraphQL resolvers are verified for Field Forge scalar values, structured Group / Repeater / Flexible Content values, and object-backed MediaItem, ContentNode, and TermNode fields. sourceUrl can be null for non-image attachments in WPGraphQL; use mediaItemUrl when you need a stable file URL. user and page_link remain scalar in the current resolver scope.


The WPGraphQL + custom fields problem

WPGraphQL is the GraphQL API layer for WordPress. It exposes posts, pages, taxonomies, and users as a GraphQL schema that a JavaScript frontend can query. To query custom fields through WPGraphQL, the fields have to be registered with it.

If you want to query custom fields via WPGraphQL, you traditionally have three options:

  1. WPGraphQL for ACF: a separate plugin for ACF field groups (its WordPress.org listing, October 2026).
  2. Custom WPGraphQL types: PHP code of your own that registers each field with WPGraphQL.
  3. Use REST API instead: the WordPress REST API returns Field Forge values too, in the fieldforge property of the post types that are shown in REST.

With Pro, Field Forge registers its types with WPGraphQL when both plugins are active, so the custom fields can be queried through GraphQL without a separate plugin.


How it works

Step 1: Install Field Forge and WPGraphQL

Both plugins must be active. WPGraphQL is the GraphQL API layer; Field Forge provides the type definitions and resolvers for custom fields.

Step 2: Field Forge detects WPGraphQL on activation

When Field Forge is activated (or WPGraphQL is activated after Field Forge), Field Forge scans your field groups and registers:

  • GraphQL types for each field group (e.g., HeroSectionFields, TeamMemberFields)
  • GraphQL types for nested repeaters, groups, and flexible content layouts
  • Union types for flexible content with multiple layouts
  • Resolvers that fetch field values from Field Forge’s custom table storage

Step 3: Query via WPGraphQL

Your custom fields are immediately queryable:

query GetPage {
  page(id: "home", idType: SLUG) {
    title
    fieldforge {
      heroSection {
        title
        subtitle
        backgroundImage {
          id
          sourceUrl
          altText
          mediaDetails {
            width
            height
          }
        }
        ctaButton {
          text
          url
          openInNewTab
        }
      }
    }
  }
}

The fieldforge key is added to every queryable post type, exposing the custom field groups assigned to that post.


Downloadable GraphQL SDL

Field Forge also lets you download the pure GraphQL Schema Definition Language (SDL) for your field groups. This is useful for:

  • Code generationtools like GraphQL Code Generator can read the SDL and produce TypeScript types
  • Documentationpublish the schema for your team or API consumers
  • Testinguse the SDL to mock responses in tests
  • Toolingschema-aware GraphQL IDEs like GraphQL Playground can auto-complete queries

Click Download GraphQL SDL in the Field Forge admin to get a .graphql file:

type HeroSectionFields {
  title: String
  subtitle: String
  backgroundImage: MediaItem
  ctaButton: CtaButtonGroup
}

type CtaButtonGroup {
  text: String
  url: String
  openInNewTab: Boolean
}

type TeamMemberFields {
  name: String
  photo: MediaItem
  bio: String
  skills: [SkillSubField]
}

type SkillSubField {
  skillName: String
  proficiency: Int
}

Nested and complex types

GraphQL handles nested types naturally. Field Forge generates:

Repeater fields → array types

type TeamPage {
  teamMembers: [TeamMemberRow]
}

type TeamMemberRow {
  name: String
  photo: MediaItem
  bio: String
}

Flexible content → union types

type LandingPage {
  pageSections: [PageSectionLayout]
}

union PageSectionLayout = HeroLayout | FeaturesLayout | CTALayout

type HeroLayout {
  title: String
  subtitle: String
  backgroundImage: MediaItem
}

type FeaturesLayout {
  sectionTitle: String
  features: [FeatureItem]
}

type CTALayout {
  headline: String
  button: ButtonGroup
}

Querying union types in GraphQL requires inline fragments:

query GetLandingPage {
  page(id: "home", idType: SLUG) {
    fieldforge {
      pageSections {
        __typename
        ... on HeroLayout {
          title
          subtitle
          backgroundImage { sourceUrl }
        }
        ... on FeaturesLayout {
          sectionTitle
          features {
            title
            description
          }
        }
        ... on CTALayout {
          headline
          button { text url }
        }
      }
    }
  }
}

This is standard GraphQL idiom. The result is a fully-typed array where each item has the right shape for its layout.


Relationship fields → connection types

Relational fields (post object, relationship, taxonomy) resolve to WPGraphQL object types:

type ProductFields {
  relatedProducts: [Post]  # Post type resolved to WPGraphQL's Post type
  author: User             # User type resolved
  category: [Category]     # Taxonomy terms resolved
}

Field Forge resolves post relationships to WPGraphQL ContentNode objects and taxonomy relationships to TermNode objects. Anonymous queries receive null or filtered lists for inaccessible private, draft, or password-protected post objects.

query GetProduct {
  post(id: "product-a") {
    fieldforge {
      productDetails {
        relatedProducts {
          title
          slug
          featuredImage {
            node {
              sourceUrl
            }
          }
        }
      }
    }
  }
}

Works with GraphQL Code Generator

If you use GraphQL Code Generator in your frontend project, the Field Forge types are part of the schema it reads. Configure codegen.yml to introspect your WordPress GraphQL endpoint:

schema: https://wp.example.com/graphql
documents: './src/**/*.graphql'
generates:
  ./src/gql/:
    preset: client
    plugins: []

Run graphql-codegen and you get typed GraphQL query hooks for your frontend, including the Field Forge types.


Field Forge vs WPGraphQL for ACF

WPGraphQL for ACF is a separate plugin for ACF field groups. Field Forge Pro registers its own types with WPGraphQL, so Field Forge fields need no separate plugin. Scalar, structured, media, post relationship, and taxonomy values are covered; user and page_link remain scalar in the current resolver scope.


How values are read

Field Forge reads the values of a post from its own table and caches them with the WordPress object cache. The repository has no benchmark of GraphQL queries, so this page quotes no figures.


Ready for GraphQL custom fields?

See pricing →

GraphQL generation and WPGraphQL integration are in every paid plan.

Forge AI Assistant Online

Hi! I'm the Field Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs