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

testCategoriesMutation fails with error #287

Open
ashtonlance opened this issue Jun 28, 2019 · 5 comments
Open

testCategoriesMutation fails with error #287

ashtonlance opened this issue Jun 28, 2019 · 5 comments

Comments

@ashtonlance
Copy link

Been banging my head trying to figure this one out. Ended up running the test and it failed with the same error I was getting in IDE.

"error": "A non well formed numeric value encountered"

PHP 7.3
Craft CMS 3.1.32.1

@dstrunk
Copy link

dstrunk commented Jun 29, 2019

@ashtonlance can you verify that the variable being passed is an integer instead of a string? what exactly is being passed … also what are you trying to do?

@ashtonlance
Copy link
Author

@dstrunk Thanks for getting back to me. Basically I'm trying to add a category to a Categories relationship field on an entry type called Projects.

Per MutationTest.php -- an object should be passed to the mutation

public function testMultiSelectMutation(): void
    {
        $input = 'mutation { story: upsertStories(title:"Multi Select Test'.date('U').'", socialLinksTwo:[fb, tw]) { id, socialLinksTwo } }';

        $result = $this->execute($input);

        $this->assertEquals('["fb","tw"]', json_encode(@$result['data']['story']['socialLinksTwo']));
    }

My code reads as:

mutation addProject($title: String!, $totalHours: Int!, $selectedCat: [CategoryCategoryInput]!)
    {
        upsertProjects(
            title: $title
            projectName: $title
            totalHours: $totalHours
            category: $selectedCat
            
        ) {
        id
        title
        totalHours
    }
}

With $selectedCat being an object looking like this [{id: 48}] -- 48 is the id of the category I want to assign to the entry.

@ashtonlance
Copy link
Author

@markhuot @dstrunk Any ideas here?

@ashtonlance
Copy link
Author

Fixed in #301

@svale
Copy link

svale commented Dec 4, 2019

Thanks @ashtonlance, #301 saved my morning!

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

No branches or pull requests

3 participants