Skip to content

Mutation definitions break code: "Uncaught Error: Function name must be a string" #1006

Answered by nleco
nleco asked this question in Q&A
Discussion options

You must be logged in to vote

I spent 2 days trying to figure it out, only to ask here and THEN figuring it out.

I had wrapped my args into an 'input' key. This is a no-no. I had to use an InputObjectType.

$CreateUserInputType = new InputObjectType([
  'name' => 'CreateUserInput',
  'fields' => [
    'name' => Type::nonNull(Type::string()),
    'email' => Type::nonNull(Type::string()),
    'password' => Type::nonNull(Type::string()),
    'password_confirmation' => Type::nonNull(Type::string()),
  ],
]);

and then use THAT as the input

$rootMutation = new ObjectType([
  'name' => 'Mutation',
  'fields' => [
    'createUser' => [
      'type' => $UserType,
      'args' => [
        'input' => [
          'type' => $Crea…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nleco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant