1

I want to register a new user in Drupal8 backend. Installed graphql in drupal8 so its working as graphql server. Installed apollo in angular5 and successfully fetched nodes and articles list. Now I want to register a user in drupal8 using graphql query from angular side.

const headers = new HttpHeaders();
headers.append("Access-Control-Allow-Origin", "*");
headers.append("Access-Control-Allow-Headers", "x-requested-with");
const submitClient = gql`mutation ($input: UserUserCreateInput!) {
  createUserUser(input: $input) {
    violations {
      path
      message
    }
    errors
    entity {
      entityId
      entityBundle
      entityLabel
    }
  }
}
`;

 this.apollo.mutate({
  mutation: submitClient,
  variables: {
    "input": {
      "name": "New Client",
      "mail": "newClient@gmail.com",
      "status": "1"
    }

  }
}).subscribe(r => console.log(r), e => console.log(e), () => console.log('done'));

This is my piece of code.

Getting a response

data:
createUserUser:
entity: null
errors: Array(1)
0: "You do not have the necessary permissions to create entities of this type."
length: 1
proto: Array(0)
violations: []
__typename: "EntityCrudOutput"
proto: Object
proto: Object

This must be because of some authentication or permission related. Please help me to figure this out. Thanks in advance.

Priya Agarwal
  • 433
  • 1
  • 4
  • 5

1 Answers1

0

I would say that you are missing permission to create user, you can test it going to admin/people/permissions and scroll to the bottom of the page and there you can find permission for creating user, add that permission to the anonymous user and then try to execute your mutation again. Hope this works.