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

[4.x]: GraphQL mutation: "We couldn't find any matching entries" when creating entry with relational fields #14801

Open
Val0che opened this issue Apr 12, 2024 · 3 comments

Comments

@Val0che
Copy link

Val0che commented Apr 12, 2024

What happened?

Description

When trying to create an entry with relational fields via a GraphQL Mutation, I got the message "We couldn't find any matching entries". It seems that the corresponding relational entry doesn't exist. But it does definitely.

When updating the entry (while passing the entryID to the mutation), it updates the relational field with the corresponding entry.

The strange thing is that it's working in graphiQL when passing all the necessary arguments except the entryID, but not in local. We also checked all the necessary permissions both in the schema and the user.

Steps to reproduce

  1. Create a mutation that saves an entry
mutation saveOffer(
    $id: ID,
    $title: String,
    $activityIds: [Int]
  ) {
    save_offer_default_Entry(
      id: $id,
      title: $title,
      activity: $activityIds
    ) {
      id
      title
      activity {
        ...on activity_default_Entry {
          id
          title
        }
      }
    }
  }
  1. Call this mutation from the front end while creating a new Offer
const { data, errors } = await saveOfferMutation(authCookie, {
  title: 'test offer',
  activityIds: [121183]
});

=> message: "We couldn't find any matching entries",

  1. Call this same method for updating an offer :
const { data, errors } = await saveOfferMutation(authCookie, {
  id: '121533',
  title: 'test offer',
  activityIds: [121183]
}); 

=> Works perfectly.

Expected behavior

Mutation to create an entry with relational fields while passing the relational field ID to work.

Actual behavior

Not working.

Thanks guys!

Craft CMS version

Craft Pro 4.8.9

PHP version

8.1.27

Operating system and version

Linux 4.19.0-22-cloud-amd64

Database type and version

MariaDB 10.4.33

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.10-23)

Installed plugins and versions

@brandonkelly
Copy link
Member

Can the schema query for entries in the activity section?

@Val0che
Copy link
Author

Val0che commented Apr 17, 2024

Yes the schema can query and mutate activity

@brandonkelly
Copy link
Member

I’m not able to reproduce this. Would you mind sending your Composer files and a database backup into support@craftcms.com? We might have better luck reproducing with those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants