Create Post
createPost
mutation is used to create a new post in a space.
It takes spaceId
and CreatePostInput
as inputs.
Each post has a type which defines the fields of it.
You can use postTypes
query to retrieve the
available post types in your community.
- GraphQL
- JS Client
mapping
field in postType defines the fields of the posts with this type.
It is an array of PostTypeMapping
.
The important attributes of it are key
, type
, and required
.
key
: the name of this field used to identify ittype
: the type of this field can be one ofPostMappingTypeEnum
required
: indicate whether this field is required when creating a post
An example of a postType can be:
This is the post type for discussion. It has 2 required fields, title
and content
.
title
should have a text value but content
can contain html.
It also has a non-required field, previewImageId
, whose type is image.
#
Create a postTo create a post you need to define its post type. We will use the discussion post type mentioned above.
The value of the fields (i.e. title
and content
) is passed in the mappingFields
.
The value should be a valid stringified json object. Typically, in JS you can use JSON.stringify()
.
- GraphQL
- JS Client
#
Reply to PostcreateReply
mutation is used to reply to a post.
It takes postId
and CreatePostInput
as inputs.
For example, we can reply with a comment on the post we created above. The post type of comment is this.
Now we can create a reply using this post type.
- GraphQL
- JS Client
#
Create Post with AttachmentsTo create a post with attachments you have to first upload the attachments using
upload files.
Then you can pass the id
s of the files as attachmentIds
.
- GraphQL
- JS Client
#
Create Post with Embedded ImageTo embed images in the post first you need to upload images.
Then you can use the mediaDownloadUrl
of the uploaded images in an img tag.
- GraphQL
- JS Client
#
Create Post with Embedded VideoTo embed videos in the post first you need to upload them.
Then you can use the mediaDownloadUrl
of the uploaded files in a video tag.
- GraphQL
- JS Client
Similarly, you can use the same approach to embed anything else (e.g. audio) to the posts.
#
Create Post with Embedded LinksYou can embed links to your post. For example, you can add a YouTube video.
- GraphQL
- JS Client