Multiple types for fields. Conflict when querying.

default discord avatar
rene.k3
3 months ago
10

I'm using the same field called

Link

in multiple collections. I'm creating the field with the Field type from payload/types. I'm importing that field in the collections where I'm using it. I'm also using the same field in blocks. My problem now is, that payload doesn't generate types for that field and when querying a collection and it's blocks where multiple blocks use that

Link

field, I'm getting a conflict error.



So basically I have multiple types for the same field. Like

Block1_Link

,

Block2_Link

,

Block3_Link

. Instead I should have

Link

as the type, anytime I use the field

Link

.



Any idea how to solve this?

  • discord user avatar
    dribbens
    Payload Team
    3 months ago

    What is the error specifically? I can understand how this would be a problem, but I'm not sure the solution and seeing the error would help.

  • default discord avatar
    rene.k3
    3 months ago
    {"message": "Fields \"link\" conflict because subfields \"type\" conflict because they return conflicting types \"Hero1_Link_type\" and \"Hero2_Link_type\" and subfields \"subtype\" conflict because they return conflicting types \"Hero1_Link_subtype\" and \"Hero2_Link_subtype\" and subfields \"coll\" conflict because they return conflicting types \"Hero1_Link_coll\" and \"Hero2_Link_coll\" and subfields \"rel\" conflict because they return conflicting types \"Hero1_Link_rel\" and \"Hero2_Link_rel\" and subfields \"target\" conflict because they return conflicting types \"Hero1_Link_target\" and \"Hero2_Link_target\" and subfields \"referrerpolicy\" conflict because they return conflicting types \"Hero1_Link_referrerpolicy\" and \"Hero2_Link_referrerpolicy\". Use different aliases on the fields to fetch both if this was intentional."}
  • discord user avatar
    jmikrut
    Payload Team
    3 months ago

    yes, we are releasing a new way to "flatten" the GraphQL types into a single reusable interface



    @dribbens we should release that feature ASAP and then comment here

  • discord user avatar
    dribbens
    Payload Team
    3 months ago

    Aye, good call!

  • default discord avatar
    rene.k3
    3 months ago

    Nice. Thanks for help guys.

  • discord user avatar
    dribbens
    Payload Team
    3 months ago

    OK 1.9.0 has it.



    Thanks for being patient.



    @rene.k3 Give it a shot and let us know

  • default discord avatar
    rene.k3
    3 months ago

    @dribbens It's awesome. It works great. I like the solution. Thanks for the quick turnaround.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.