RFC 3 / Accepted

Update description of Fragments to emphasize evolving data needs

Opened on
Merged on

At a glance

Project
GraphQL Spec
Identifier
#1193
Stage
RFC 3 / Accepted
Champion
@janettec
Updated
2026-03-19
Latest activity
Pull request merged on
Source

Pull request description

Why these changes?

Fragments are not for reuse.

The current language in section 2.8 on Fragments, namely the sentence...

Fragments allow for the reuse of common repeated selections of fields, reducing duplicated text in the document.

...encourages using fragments to deduplicate common selections, even if those selections represent independent data needs.

For example, let's consider these two functions

// This function formats a post for display in a feed
func formatPostForFeed(post: PostDisplayFragment) -> String {
 let authorName = post.author.name
 let contentText = post.content.text

 return "\(authorName) posted: \(contentText)"
}

// This function formats a post for notification purposes
func formatPostForNotification(post: PostDisplayFragment) -> String {
 let authorName = post.author.name
 let contentText = post.content.text

 return "New post from \(authorName): \(contentText)"
}

Given these two functions currently both use authorName and contentText, the current language in the spec encourages one to write a fragment

fragment PostDisplayFragment on Post {
 author
 content
}

If formatPostForFeed now needs timestamp, we will add naturally add timestamp to PostDisplayFragment

// This function formats a post for display in a feed
func formatPostForFeed(post: PostDisplayFragment) -> String {
 let authorName = post.author.name
 let contentText = post.content.text
 let timestamp = post.createdAt.formatted // Added

 return "\(authorName) posted: \(contentText)\nPosted \(timestamp)"
}
fragment PostDisplayFragment on Post {
 author
 content
 timestamp # Added
}

If we have the following queries

query NotificationQuery {
 ...PostDisplayFragment # Over-fetching timestamp
}

query FeedQuery {
 ...PostDisplayFragment
}

notice how NotificationQuery is now over-fetching timestamp!

The key observation is that formatPostForFeed and formatPostForNotification are two independent functions, so by having them both rely on a single fragment to express their data needs, we are creating a dependency where one should not exist (because that dependency does not exist in the product logic itself).

What are the proposed changes?

Updated:

  1. The description for why one might use fragments
  2. The first GraphQL example in section 2.8

The goal is to emphasize that fragments support evolving data needs (as opposed to recommending people identify common selections that are currently in an executable document).

Open to any and all feedback on the motivation for the change and how it's communicated via changes in the spec language!

Timeline

February 2026

  • Pull request merged on by leebyron
  • @leebyron committed "Apply suggestion from @benjie" on
  • Discussed in GraphQL WG

    The GraphQL Technical Steering Committee (TSC) meeting focused on several key topics including field extensions, fragment reusability, and AI working group updates. The group discussed a proposal for compile-only directives and runtime schemas, with Mark presenting ideas for distinguishing between human-readable schema files and actual runtime schemas. Lee emphasized the importance of separating runtime and compile-time concerns to improve tooling and resilience. The meeting also covered updates on the AI working group's progress with semantic introspection and subschema concepts, with Kewei presenting on these initiatives. Additionally, Martin reported that the nullability working group would be archiving their repository, as consensus had been reached on service capabilities and on-error request flags. The conversation ended with discussions about GraphQL Conference CFPs and upcoming working group sessions on incremental delivery and the Golden Path.

    Zoom summary · GraphQL WG · 2026-02-05
    Next Steps

    Lee: Merge the "fragments are not for reuse" PR and make minor copy edits as needed.

    Zoom summary · GraphQL WG · 2026-02-05

January 2026

  • Advanced to RFC 3 on by benjie
  • Discussed in GraphQL WG

    graphql/graphql-spec#1193

    Meeting notes · GraphQL WG · 2026-01-15

    NYC (Jeanette/Matt): Address any final editorial feedback on the fragment reuse PR and respond to comments for final merge.

    Zoom summary · GraphQL WG · 2026-01-15

    The meeting focused on schema construction and editing in GraphQL. Lee and Bjorn discussed the distinction between constructing and representing schemas, with Lee suggesting that the scope of an RFC should be about constructing schemas rather than representing them. Pascal proposed creating a playground for experimenting with new syntax features, similar to TypeScript's relationship with JavaScript. Bjorn expressed interest but noted he might not be the best person to champion this effort forward. Mark offered to help reframe the proposal and suggested continuing the discussion on Discord. The conversation ended with Jeanette inquiring about the status of her PR related to fragment reuse, which Lee indicated was likely ready for final review and merge.

    Zoom summary · GraphQL WG · 2026-01-15

November 2025

  • Discussed in GraphQL WG

    The Apollo Working Group meeting covered TSC elections, grants, and updates to the GraphQL specification, including discussions on object identification and fragment usage. The team agreed on implementing a regular release schedule and discussed various GraphQL capabilities, including error handling modes and schema introspection. They also reviewed specifications for service capabilities and stream features, while addressing questions about back compatibility and runtime introspection.

    Zoom summary · GraphQL WG · 2025-11-06
    Next Steps

    Lee: Do editorial pass on Jeanette's fragment descriptions PR and merge it

    Zoom summary · GraphQL WG · 2025-11-06
    Next Steps

    Lee: Ensure GraphQL documentation for fragments mirrors the spec changes with elaborated best practices

    Zoom summary · GraphQL WG · 2025-11-06

    GraphQL Fragment Documentation Updates

    The team discussed updating the GraphQL specification to better explain the purpose and usage of fragments. Jeanette proposed changes to emphasize that fragments should map to client logic components and help with evolving data needs. Benjie argued for a stronger recommendation of a specific naming convention and pattern for fragments, while Lee suggested adding this information to non-normative notes in the specification. The team agreed that while the spec should remain minimal, the documentation could provide more detailed guidance on best practices for using fragments.

    Zoom summary · GraphQL WG · 2025-11-06

October 2025

  • @janettec committed "Respond to feedback from last working group meeting" on
  • Discussed in GraphQL WG

    Various technical discussions took place regarding specification updates, documentation contributions, and ongoing issues with filtering and querying in GraphQL, with the team addressing these challenges through proposed solutions and future planning.

    Zoom summary · GraphQL WG · 2025-10-02
    Next Steps

    Jeanette to update the PR for fragments in the spec by removing the "fake function name" and proposing options for the term "modularity".

    Zoom summary · GraphQL WG · 2025-10-02
    Next Steps

    TSC members to review and approve Jeanette's PR on fragments description in the spec.

    Zoom summary · GraphQL WG · 2025-10-02

    Fragments Specification Update Discussion

    The team discussed a pull request to update the description of fragments in the specification. Jeanette explained the proposed changes to better reflect the intended use of fragments for evolving data needs rather than for extracting common selections from executable documents. Benjie suggested the changes were editorial and did not require an RFC, while the team agreed on the importance of improving the wording to avoid confusion. They decided to merge the PR after making some suggested changes, such as removing references to "client logic" and considering alternative wording for "modularity." Lee supported the idea of merging the PR when there is general agreement, allowing further refinement if needed before the next meeting.

    Zoom summary · GraphQL WG · 2025-10-02

    The team discussed the importance of editorial changes in specifications, noting that many such changes uncover esoteric bugs and improve clarity. They emphasized the value of contributing to specifications and using Discord workgroup channels for quick feedback. Benjie shared details from a secondary meeting with Mark about addressing issues with polymorphic types and server-driven UI, where empty objects could be returned for unsupported widget types. The team explored potential solutions, including passing arguments to fields to specify supported widget types.

    Zoom summary · GraphQL WG · 2025-10-02

September 2025