Create Space
createSpace
mutation is used to create a new space.
It takes CreateSpaceInput
as an input.
- GraphQL
- JS Client
mutation {
createSpace(input: {
name: "New Space"
}) {
id
}
}
client.spaces.create({ input: { name: 'New Space' } })
This will create a new space with the name "New Space" inside the default collection.
Create a space inside a collectionโ
You can pass the id
of the collection to create the space inside it.
Let's first create a collection.
- GraphQL
- JS Client
mutation {
createCollection(input: {name: "Get Started"}) {
id
}
}
client.collections.create({ input: { name: 'Get Started' } })
The response will contain the id
of the collection.
{
"data": {
"createCollection": {
"id": "cj9zfkqj"
}
}
}
Then you can use the collectionId
to create the space inside the collection.
- GraphQL
- JS Client
mutation {
createSpace(input: {
name: "Say Hello"
collectionId: "cj9zfkqj"
}) {
id
}
}
client.spaces.create({ input: { name: 'New Space', collectionId: 'cj9zfkqj' } })
This will create a space with the name "Say Hello" inside the collection "Get Started".
Create a space with an emoji as imageโ
You can also create a space with an emoji as image.
You need to create an emoji first and then use the id
of the emoji as imageId
.
- GraphQL
- JS Client
mutation {
createEmojis(input: [{text: "+1"}]) {
id
}
}
client.media.createEmojis([{ text: '+1' }])
- GraphQL
- JS Client
mutation {
createSpace(input: {
name: "Say Hello"
collectionId: "cj9zfkqj"
imageId: ":+1:"
}) {
id
}
}
client.spaces.create({ input: { name: 'New Space', collectionId: 'cj9zfkqj', imageId: ":+1:" } })
This will create a space with a Thumbs Up emoji (๐) as image.
Create a space with an imageโ
To create a space with an image first you need to upload an image.
And then you can use the id
of the image as imageId
.
- GraphQL
- JS Client
mutation {
createSpace(input: {
name: "Say Hello"
collectionId: "cj9zfkqj"
imageId: "sDJnsABrHAqd"
}) {
id
}
}
client.spaces.create({ input: { name: 'New Space', collectionId: 'cj9zfkqj', imageId: "sDJnsABrHAqd" } })