'Can i extend graphql fragments?

For example, i have the next query for the paragraph:

query ParagraphText {
  field_title
  field_body
  field_subtitle
  field_image
  field_button
}

And i use this paragraph on the front page. But also i use this paragraph on another page but i dont want this query to have button. Is there an opportunity to extend fragment?

fragment ParagraphText on paragraph__text {
  field_title
  field_body
  field_subtitle
  field_image
}

fragment ParagraphTextWithButton extends ParagraphText {
  field_button
}


Solution 1:[1]

You can expand a fragment in a fragment definition to do this:

fragment ParagraphText on paragraph__text {
  field_title
  field_body
  field_subtitle
  field_image
}

fragment ParagraphTextWithButton on paragraph__text {
  ...ParagraphText
  field_button
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 coreyward