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

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

For greater control, create an ObjectDataSenderBuilder for the Space.ONE_SPACE_QUERY_OBJECT_NAME object, adding the Space id attribute, passing in Space fields and children. Instantiate a new SpaceGraphQLQuery passing in the ObjectDataSenderBuilder as the parameter. Then pass this to WWClient.getSpaceWithQuery().

Space Members

While developing the SDK, it was expected that getting members for a Space would be a common requirement. Consequently the org.opencode4workspace.builders.SpaceMembersGraphQLQuery class has a simple static helper method, buildSpaceMembersGraphQueryWithSpaceId(String). Similar methods are also available from WWClient and WWGraphQLEndpoint.

For greater control, create an ObjectDataSenderBuilder for the Space.ONE_SPACE_QUERY_OBJECT_NAME object, adding the Space id attribute, passing in Space fields and children. Instantiate a new SpaceMembersGraphQLQuery passing in the ObjectDataSenderBuilder as the parameter. Then pass this to WWClient.getSpaceMembersWithQuery().

Examples

    Space space = client.getSpaceById(spaceId);
    assert (space.getMembers().size() > 0);
    ObjectDataSenderBuilder query = new ObjectDataSenderBuilder();
    query.setObjectName(Space.ONE_SPACE_QUERY_OBJECT_NAME);
    query.addAttribute(SpaceAttributes.ID, spaceId);
    query.addField(SpaceFields.ID);
    query.addField(SpaceFields.TITLE);
    query.addField(SpaceFields.DESCRIPTION);

	Space spaceResult = client.getSpaceWithQuery(new SpaceGraphQLQuery(query));
    List<Person> members = client.getSpaceMembersById(spaceId);
    assert (members.size() > 0);
    ObjectDataSenderBuilder query = new ObjectDataSenderBuilder();
    query.setObjectName(Space.ONE_SPACE_QUERY_OBJECT_NAME);
    query.addAttribute(SpaceAttributes.ID, spaceId);
    ObjectDataSenderBuilder members = new ObjectDataSenderBuilder(SpaceChildren.MEMBERS.getLabel(), true);
    members.addField(PersonFields.ID);
    members.addField(PersonFields.PHOTO_URL);
    members.addField(PersonFields.EMAIL);
    members.addField(PersonFields.DISPLAY_NAME);
    members.addChild(new BasicCreatedByUpdatedByDataSenderBuilder(PersonChildren.CREATED_BY));
    members.addChild(new BasicCreatedByUpdatedByDataSenderBuilder(PersonChildren.UPDATED_BY));
    query.addChild(members);

	List<Person> members = client.getSpaceMembersWithQuery(new SpaceMembersGraphQLQuery(query));