craftcms / craftcms/cms

GraphQL inline fragments not required?

Open
#7,165 2 comments 0 reactions 1 assignee View on GitHub

@andris-sevcenko is already working on this.

Since Nov 23, 2020.

bug graphql :gear:
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

Description

In GraphQL I seem to be able to access custom fields on entries without inline fragments. Is this a bug or a feature?

Currently this query returns the correct data without error:

entries {
  customField
}

However as far as I can tell, the inline fragment should be required:

entries {
  ...on section_entrytype_Entry {
    customField
  }
}

While I think this is currently a bug, it is actually quite useful as the site has many entry types with shared custom fields which would result in a huge query similar but multiple times larger than:

entries {
  ...on section_entrytype1_Entry {
    customField1
    customField2
    customField3
  }
  ...on section_entrytype2_Entry {
    customField1
    customField2
    customField3
  }
  ...on section_entrytype3_Entry {
    customField1
    customField2
    customField3
  }
}
Additional info
  • Craft version: 3.5.14
  • PHP version: 7.3.19
  • Database driver & version: MySQL 8.0.20
  • Plugins & versions:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.