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

Core Data: Fix the 'query._fields' property check inside 'getEntityRecord' resolver #65079

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core-data/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const getEntityRecord =
}
);

if ( query !== undefined ) {
if ( query !== undefined && query._fields ) {
query = { ...query, include: [ key ] };

// The resolution cache won't consider query as reusable based on the
Expand Down
10 changes: 1 addition & 9 deletions packages/core-data/src/test/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ describe( 'getEntityRecord', () => {

it( 'accepts a query that overrides default api path', async () => {
const query = { context: 'view', _envelope: '1' };
const queryObj = { include: [ 'post' ], ...query };

const select = {
hasEntityRecords: jest.fn( () => {} ),
Expand All @@ -98,13 +97,6 @@ describe( 'getEntityRecord', () => {
query
)( { dispatch, select, registry } );

// Check resolution cache for an existing entity that fulfills the request with query.
expect( select.hasEntityRecords ).toHaveBeenCalledWith(
'root',
'postType',
queryObj
);

// Trigger apiFetch, test that the query is present in the url.
expect( triggerFetch ).toHaveBeenCalledWith( {
path: '/wp/v2/types/post?context=view&_envelope=1',
Expand All @@ -116,7 +108,7 @@ describe( 'getEntityRecord', () => {
'root',
'postType',
POST_TYPE,
queryObj
query
);

// Locks should have been acquired and released.
Expand Down
Loading