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

The "me" and "person" queries both return a Person object. The "person" query requires a mandatory attribute for either the id or the name of the Person to return.

NOTE

The "me" query and "person(email)" query can only be called from a user-authenticated WWClient. They cannot be called from an application-authenticated WWClient. At the time of writing, attempting to call those queries from an application-authenticated WWClient just return an HTTP 500 error. This is because those queries are looking for people within your organisation. But an application does not have an organisation.

The org.opencode4workspace.builders.PersonGraphQLQuery class has three simple static helper methods available:

  • buildMyProfileQuery()
  • buildPersonQueryByEmail(String)
  • buildPersonQueryById(String)

If the parameter is blank, the query will redirect to buildMyProfileQuery() to process the "me" query. Similar methods are also available from WWClient and WWGraphQLEndpoint.

For greater control, create an ObjectDataSenderBuilder for either the Person.MY_PROFILE_QUERY_OBJECT_NAME (i.e. "me") or Person.ONE_PERSON_QUERY_OBJECT_NAME (i.e. "person") object, adding attributes as appropriate, passing in Person fields and children. Instantiate a new PersonGraphQLQuery(String, Object) passing in PersonGraphQLQuery.METHOD_GET_MYSELF or PersonGraphQLQuery.METHOD_GET_PROFILE (or an arbitrary method name) as the first parameter and the ObjectDataSenderBuilder as the second. Then pass this to WWClient.getPersonWithQuery().

Examples

Basic getMe
    Person me = client.getMe();
    assert (myDisplayName.equals(me.getDisplayName()));
Basic getProfileById
    Person person = client.getPersonById(profileId);
    assert (myDisplayName.equals(person.getDisplayName()));
Basic getPofileByEmail
    Person person = client.getPersonByEmail(profileEmail);
    assert (myDisplayName.equals(person.getDisplayName()));
Customised getProfile
    ObjectDataSenderBuilder query = new ObjectDataSenderBuilder();
    query.setObjectName(Person.ONE_PERSON_QUERY_OBJECT_NAME);
    query.addAttribute(PersonAttributes.ID, personId);
    query.addField(PersonFields.ID);
    query.addField(PersonFields.DISPLAY_NAME);
    query.addField(PersonFields.EMAIL);
    query.addField(PersonFields.PHOTO_URL);
    query.addChild(new BasicCreatedByUpdatedByDataSenderBuilder(PersonChildren.CREATED_BY));
    query.addChild(new BasicCreatedByUpdatedByDataSenderBuilder(PersonChildren.UPDATED_BY));
	Person person = client.getPersonWithQuery(new PersonGraphQLQuery(query));
    assert (myDisplayName.equals(person.getDisplayName()));
Write a comment…