Page tree
Skip to end of metadata
Go to start of metadata

The "message" query returns a specific Message. The query requires a mandatory attribute for the id of the Message to retrieve.

The org.opencode4workspace.builders.MessageGraphQLQuery class has a simple static helper method, buildMessageGraphQueryWithMessageId(String). Similar methods are also available from WWClient and WWGraphQLEndpoint.

For greater control, create an ObjectDataSenderBuilder for the Message.ONE_MESSAGE_QUERY_OBJECT_NAME object, adding the Message id attribute, passing in Message fields and children. Instantiate a new MessageGraphQLQuery passing in the ObjectDataSenderBuilder as the parameter. Then pass this to WWClient.getMessageWithQuery().

Examples

Basic getMessage
    Message message = client.getMessageById(messageId);
    assert (!"".equals(message.getContentType()));
getMessageWithQuery
    ObjectDataSenderBuilder query = new ObjectDataSenderBuilder();
    query.setObjectName(Message.ONE_MESSAGE_QUERY_OBJECT_NAME);
    query.addAttribute(MessageAttributes.ID, messageId);
    query.addField(MessageFields.CONTENT_TYPE);
    query.addField(MessageFields.CONTENT);
    query.addField(MessageFields.ANNOTATIONS);
        
    Message message = client.getMessageWithQuery(new MessageGraphQLQuery(query));
Write a comment…