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

PostFormat is not set when Contribute/Author uses createPost or updatePost mutations #3135

Open
2 of 3 tasks
tuanfront-end opened this issue May 21, 2024 · 3 comments
Open
2 of 3 tasks
Labels
Status: 🚀 Actionable Issues that have been curated, have enough info to take action, and are ready to be worked on Type: Bug Something isn't working

Comments

@tuanfront-end
Copy link

Description

Use createPost and updatePost mutations to create a new post and update the post with input postFormats:

  1. If the user has the admin role then everything works as expected, postFormat will be set up properly.
  2. If the user has the Contribute/Author role then postFormat will not be set correctly:
  • With createPost mutation, postFormat will always be empty [].
  • With updatePost mutation, postFormat will always keep its old value.

Steps to reproduce

  1. I use Faustjs for my project, and use the useLogin feature for login
  2. Try logging in with accounts with different roles and test with this query:
mutation MyMutation {
  createPost(
    input: {title: "This is title", postFormats: {append: false, nodes: {name: "video"}}}
  ) {
    post {
      title
      id
      postFormats {
        nodes {
          id
          name
          slug
        }
      }
    }
  }
}

Additional context

No response

WPGraphQL Version

1.26.0

WordPress Version

6.5.3

PHP Version

7.4

Additional environment details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.
@josephfusco josephfusco added the Needs: Reproduction This issue needs to be reproduced independently. label May 21, 2024
@jasonbahl
Copy link
Collaborator

@tuanfront-end is there an error returned? Does the postFormats field exist in the schema but it's not resolving? or is it not in the Schema at all?

Can you share a bit more about the actual behavior vs. the expectation? Maybe some screenshots of using the GraphiQL IDE, etc?

@josephfusco josephfusco added the Status: Awaiting Author Response Additional information has been requested from the author label Jun 3, 2024
@josephfusco
Copy link
Member

Hey @tuanfront-end we were able to reproduce this. Here are the steps taken so far:

  • Setup fresh WordPress install w/ an admin user and author.
  • As an author, created a post using WordPress admin, and confirmed that an author can save a draft or published post with a post format assigned.
  • Ran the following mutation
mutation MyMutation {
  createPost(
    input: {title: "This is title", postFormats: {append: false, nodes: {name: "video"}}}
  ) {
    post {
      title
      id
      postFormats {
        nodes {
          id
          name
          slug
        }
      }
    }
  }
}
  • observed that the post format was not assigned, confirming that WPGraphQL is NOT behaving the same in WordPress admin

Notes: possibly related, the capability check towards the bottom of PostObjectMutation.php

@josephfusco josephfusco added Type: Bug Something isn't working Status: 🚀 Actionable Issues that have been curated, have enough info to take action, and are ready to be worked on and removed Needs: Reproduction This issue needs to be reproduced independently. Status: Awaiting Author Response Additional information has been requested from the author labels Jun 3, 2024
@tuanfront-end
Copy link
Author

@jasonbahl @josephfusco sorry for the late reply and thanks for your great work, hope the problem will be resolved soon 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: 🚀 Actionable Issues that have been curated, have enough info to take action, and are ready to be worked on Type: Bug Something isn't working
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants