Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL schema for multiple collections with Bard+Sets is invalid #5211

Open
dmgawel opened this issue Feb 7, 2022 · 6 comments
Open

GraphQL schema for multiple collections with Bard+Sets is invalid #5211

dmgawel opened this issue Feb 7, 2022 · 6 comments

Comments

@dmgawel
Copy link
Contributor

dmgawel commented Feb 7, 2022

Bug description

When there is more than one collection that has a Bard field with Sets, the generated GraphQL schema is invalid. List of possible Sets from one of the Bard fields is used for all other collections.

How to reproduce

  1. Create two collections, "aaa" and "bbb".
  2. Add a Bard field named content to both of them.
  3. Add different sets to the content field for both collections and add sample fields (can be text type) inside sets
  4. Visit GraphiQL Explorer and try to fetch entries including content field on both Entry_Aaa_Aaa and Entry_Bbb_Bbb. You'll see that sets for Entry_Bbb_Bbb are used for Entry_Aaa_Aaa as well (could be the other way, I'm not sure what the rule is here, but looks like it's alphabetical).

Logs

No response

Versions

Statamic 3.2.32 Pro
Laravel 8.82.0
PHP 8.0.15
No addons installed

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

@jasonvarga
Copy link
Member

The types get created as Set_BardFieldHandle_SetFieldHandle.

Looks to me like you get only the sets for the first field Bard that Statamic encounters, if they're named the same.

A workaround for now is to name your fields differently across collections.

@dmgawel
Copy link
Contributor Author

dmgawel commented Feb 7, 2022

Thanks @jasonvarga 🙇‍♂️ I've renamed a Bard field in a second collection to content2 and schema generation works again. That will do as a workaround, I'll leave the issue open for a more generic solution (that will allow us to give a content name to all Bard fields across collections).

@panr
Copy link

panr commented Jun 7, 2022

Hey, any chance to fix it anytime soon? We are using the workaround from @jasonvarga comment, but sometimes it's easy to forget about it ;-)

@lotarbo
Copy link

lotarbo commented Mar 13, 2023

still same problem, we use block content system for all collections, so its very strange to have different field name for this

ps this issue not only for bard, we use replicator field

@buffalom
Copy link
Contributor

I would like to have a go at fixing this, but I need your help on how to approach it.

Presumably just adding the blueprint's handle to the type is not the way to go as this would not solve the issue for nested bards/replicators and it would be a breaking change.

Do you have any idea how you would like this to be solved?

@jasonvarga
Copy link
Member

jasonvarga commented Jun 29, 2023

An idea for a potential solution. Maybe we can have a config setting on the field that lets you give a custom GraphQL handle to the field to make it more unique across collections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants