statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.66k stars 501 forks source link

Bard/Replicator `gqlSetsTypeName()` names are not unqiue #9414

Closed arcs- closed 6 months ago

arcs- commented 6 months ago

Bug description

I have a multiple fieldsets that have a Bard element with the handle "text". These Bards have different configurations (one has sets, the other one does not). The issue is that gqlSetsTypeName() returns the bards having the same name (Sets_Text), which causes an issue when querying subsets in Graphql: Undefined array key "set handle" because it looks in the first version it got.

My first Idea would be to add the Fieldset handle to the name as well, however, I do not know how or if this would be appropriate.

How to reproduce

Fieldset A

When calling gqlSetsTypeName() on each I Get Sets_Text, even though fieldset C has a different configuration. The set configuration does not have a handle, however, adding one doesn't seem to help.

query Test {
  entry(uri: "/test") {
    ... on Entry_Pages_Page {
      id
      components {
        ... on Set_Components_Text {
          text {

            <-- here I should be able to "... on FieldsetC Subset"
                but GQL thinks this is the first Version of Bard text and therefor does not have subsets

            ... on BardText {
              type
            }

          }
        }
      }
    }
  }
}

renaming one of the "text" to e.g. "content" solves the issue, however, I don't think this is a good solution.

Logs

Undefined array key "test"

Illuminate\Foundation\Bootstrap\HandleExceptions:handleError

    public function types(): array

    {

        return $this->types;

    }

    public function resolveType($value)

    {

        return GraphQL::type($this->typeMap[$value['type']]);

    }

Illuminate\Foundation\Bootstrap\HandleExceptions:Illuminate\Foundation\Bootstrap\{closure}
Statamic\GraphQL\Types\ReplicatorSetsType:resolveType
Statamic\GraphQL\Types\BardSetsType:resolveType
GraphQL\Executor\ReferenceExecutor:completeAbstractValue
GraphQL\Executor\ReferenceExecutor:completeValue
GraphQL\Executor\ReferenceExecutor:completeValueCatchingError
GraphQL\Executor\ReferenceExecutor:completeListValue
GraphQL\Executor\ReferenceExecutor:completeValue

...

Environment

Environment
Application Name: XXX
Laravel Version: 10.42.0
PHP Version: 8.2.15
Composer Version: 2.5.5
Environment: local
Debug Mode: ENABLED
URL: xxx.novu.io
Maintenance Mode: OFF

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

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / daily, sentry
Mail: sendmail
Queue: sync
Session: file

Sentry
Enabled: MISSING DSN
Environment: local
Laravel SDK Version: 4.1.2
PHP SDK Version: 4.4.0
Release: 412695d
Sample Rate Errors: 100%
Sample Rate Performance Monitoring: 1%
Sample Rate Profiling: 1%
Send Default PII: ENABLED

Statamic
Addons: 2
Antlers: runtime
Stache Watcher: Disabled
Static Caching: Disabled
Version: 4.40.0.2 PRO

Statamic Addons
cnj/seotamic: 4.0.1
ndx/statamic-bard-color-picker: 1.2.0

Installation

Existing Laravel app

Antlers Parser

None

Additional details

No response

duncanmcclean commented 6 months ago

This sounds related to #5211 and #7772.