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

fix posts are failing to be created as Admin user #9533

Merged
merged 1 commit into from
Jan 2, 2024
Merged
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 datahub-web-react/src/app/settings/posts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const addToListPostCache = (client, newPost, pageSize) => {
});

// Add our new post into the existing list.
const newPosts = [newPost, ...(currData?.listPosts?.posts || [])];
const newPosts = [...(currData?.listPosts?.posts || [])];
Copy link
Collaborator

@jjoyce0510 jjoyce0510 Dec 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this fixing the issue? This is just removing the new post from being added to the local cache, but isn't going to fix the network error, right?

Copy link
Contributor Author

@gaurav2733 gaurav2733 Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a network error; we're successfully creating a post. However, we're trying to add static frontend data (title and description) to the local cache. The issue is that the local cache requires additional fields in the new post (but we have only title and description), which causes an error and leads to the catch block being triggered. To fix this, I removed the new post and updated code to [...(currData?.listPosts?.posts || [])] . The error occurs because the local cache needs more fields for the new post. Specifically, the new post should have these fields:{
"urn",
"type",
"postType": "Post type",
"content": {
"contentType": "TEXT",
"title",
"description",
"link": null,
"media": null
}
}
And currently, we're only adding the title and description to the local cache using the onCreate method as follows:
onCreate={(urn, title, description) => {
addToListPostCache(
client,
{
urn,
properties: {
title,
description: description || null
}
},
pageSize
);
setTimeout(() => refetch(), 2000);
}}
I also added screencast how this error is occuring with the newpost
Screencast from 02-01-24 12:08:39 PM IST.webm


// Write our data back to the cache.
client.writeQuery({
Expand Down
Loading