cms icon indicating copy to clipboard operation
cms copied to clipboard

v4.50.0 changes naming of nested GraphQL fragments

Open el-schneider opened this issue 1 year ago • 11 comments

Bug description

Fragments names for nested fields have changed. I will try to add more detail later.

Before:

fragment SetButtons on Set_TextRich_Buttons {
   ...
}

After:

fragment SetButtons on Set_PageBuilder_TextRich_Buttons {
   ...
}

How to reproduce

Upgrade to 4.50.0

Logs

No response

Environment

Environment
Laravel Version: 9.52.16
PHP Version: 8.3.3
Composer Version: 2.7.1
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Antlers: runtime
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.50.0 PRO

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

Runtime (default)

Additional details

No response

el-schneider avatar Mar 02 '24 10:03 el-schneider

Can you provide the YAML file contents for the relevant blueprint?

duncanmcclean avatar Mar 04 '24 12:03 duncanmcclean

Sure, here it is

page_builder.yaml

title: 'Page Builder'
fields:
  -
    handle: page_builder
    field:
      sets:
        main:
          sets:
            text:
              fields:
                -
                  import: page_builder_text

page_builder_text.yaml

title: 'Page Builder Text'
fields:
  -
    handle: text_rich
    field: common.text_rich

common.yaml

title: Common
fields:
  - handle: text_rich
    field:
      sets:
        main:
          sets:
            buttons:
              display: Buttons
              instructions: null
              icon: direction-buttons
              fields:
                - import: buttons
      type: bard

buttons.yaml

title: Buttons
fields:
  - handle: buttons
    field:
      fields:
        - import: button
      type: grid

el-schneider avatar Mar 05 '24 09:03 el-schneider

Same behaviour here since the update to v4.51

We have two replicators with the handles:

  • components
  • sidebar_components

Each replicator contains a set of fieldtypes which we define in the frontend as reusable query string for graphql. Before the update we could use the same string "fragment" for both replicators:

export const ComponentLinks = `
    type
    heading
    links {
      ... on Set_Links_Links {
        id
        link
        title
      }
    }
`

So e.g. to fetch the replicator on the page:

components {
  ... on Set_Components_Links {
      ${ComponentLinks}
  }
}

sidebar_components {
   ... on Set_SidebarComponents_Links {
      ${ComponentLinks}
   }
}

Since the update it is necessary to prefix the Set_Links_Link with the parent replicator handle:

export const ComponentLinks = `
    type
    heading
    links {
      ... on Set_Components_Links_Links {
        id
        link
        title
      }
    }
`

export const SidebarComponentLinks = `
    type
    heading
    links {
      ... on Set_SidebarComponents_Links_Links {
        id
        link
        title
      }
    }
`

Kylewalow avatar Mar 05 '24 12:03 Kylewalow

Would you be able to confirm the exact version where this behavior starts changing?

jasonvarga avatar Mar 05 '24 14:03 jasonvarga

We updated from v4.46 to v4.51 Just tested it: v4.49 works -> v4.50 needs the query changes

Kylewalow avatar Mar 05 '24 14:03 Kylewalow

Yes, can confirm that. It starts with 4.50

el-schneider avatar Mar 05 '24 15:03 el-schneider

Thank you

jasonvarga avatar Mar 05 '24 21:03 jasonvarga

Yes this is currently preventing us from updating Statamic, as it breaks all defined graphQL fragments in the application.

thomas4Bitcraft avatar May 06 '24 13:05 thomas4Bitcraft

We are also blocked from upgrading Statamic for the same reason. We've locked the version to 4.49 for now.

JeremyDunn avatar Jun 03 '24 18:06 JeremyDunn

What is the status of this issue? The ticket has been open since March. Does this mean that the GraphQL nested fields schema has changed permanently? We are also blocked from updating Statamic as many GraphQL fragments broke.

kamilmm21 avatar Jul 15 '24 09:07 kamilmm21

I understand this has unintentionally changed at some point which shouldn't have in a non-breaking release.

However, I don't see why it's stopping you from updating. Statamic 5 is a major release with breaking changes. Can't you also change your queries to use the updated names as part of the update?

-fragment SetButtons on Set_TextRich_Buttons {
+fragment SetButtons on Set_PageBuilder_TextRich_Buttons {

These new names seem more correct as they are scoped to the field.

jasonvarga avatar Jul 15 '24 14:07 jasonvarga