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] Multiple aliases for single matrix field #5008

Open
gregorterrill opened this issue Sep 27, 2019 · 0 comments

Comments

@gregorterrill
Copy link

commented Sep 27, 2019

Description

It doesn't seem like its currently possible to query the same matrix field multiple times (with different aliases) for different block types. I want to be able to do something like this in order to group blocks by their type:

alias1: matrixFieldHandle(type:"blockType1Handle") {
  ...on matrixFieldHandle_blockType1Handle_BlockType {
    fieldA
    fieldB
    fieldC
  }
}

alias2: matrixFieldHandle(type:"blockType2Handle") {
  ...on matrixFieldHandle_blockType2Handle_BlockType {
    fieldD
    fieldE
    fieldF
  }
}

When I try this, only the last alias (alias2 here) listed gets populated with data and any preceding aliases (just alias1 here) are an array containing a single empty object. If I switch the order and put alias2 first, then it's the array/empty object and alias1 gets populated properly with data. I'm not sure if this is a bug?

If I remove the type parameters, each alias gets all the matrix blocks from the field, but since some don't match the fragment, I get an array of mostly empty objects. The ones that do match have all the correct data though.

Additional info

  • Craft version: 3.3.5
  • PHP version: 7.1.18
  • Database driver & version: MySQL 5.7.21
  • Plugins & versions: N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.