User

Model

See schema for more information about the schema.

type User {
id: UUID!
isActive: Boolean!
email: String!
name: String!
ref: String
roles: [Role]
profileImage: String!
language: Language!
extraFields: JSONString!
}

Queries

Get users

Get a list of all users in your organisation

query users {
user {
ref
name
email
isActive
}
}

Get user

Get a single user in your organisation. You can use the ref of the user to get it.

query user {
user(ref: "user-ref") {
ref
name
email
isActive
}
}

Mutations

Create user

Create a new user in your organisation, you can pass your own custom ref.

mutation createUser {
createUser(sendInvite: true, user: {ref: "user-ref", name: "Test User", email: "test@example.com"}) {
user {
ref
name
email
}
}
}

Update user

Update a user using ref.

mutation updateUser {
updateUser(ref: "user-ref", user: {name: "New name"}) {
user {
ref
name
email
}
}
}

Update or Create User

The create user will give an error when a user already exists, to prevent doing two requests each times to create and/or update an user we can send a updateOrCreate request. You can use a ref or email as the selector, if no user is found with this selector it will create a new one.

# Use ref
mutation updateOrCreateUser {
updateOrCreateUser(ref: "user-ref", user: {name: "New name", email: "test@example.com"}) {
created # Is the user created.
user {
ref
email
name
}
}
}
# Use email
mutation updateOrCreateUser {
updateOrCreateUser(email: "test@example.com", user: {name: "New name", email: "test@example.com"}) {
created # Is the user created.
user {
ref
email
name
}
}
}

Archive user

To disable a user we can archive it. This can be done via the updateUser mutation.

mutation updateUser {
updateUser(ref: "user-ref", user: {isActive: false}) {
user {
ref
name
isActive
}
}
}