Skip to content

Commit

Permalink
Added query functionality for non-connection fields
Browse files Browse the repository at this point in the history
  • Loading branch information
klaasvandeweerdt committed Jun 25, 2023
1 parent 3014657 commit 0352b7b
Show file tree
Hide file tree
Showing 109 changed files with 4,540 additions and 22 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,22 @@ foreach (Person person in people)
##### Specific fields
```csharp
DataList<Person> people = await client.Get(Query.Person
.Select(PersonField.ID, PersonField.Name, PersonField.CustomFields));
.Select(PersonField.ID, PersonField.Organization, PersonField.Name, PersonField.CustomFields));
```
By using the `Select` method on the `Query.Person` object, you can specify the fields you want to include in the response.
The example shows the selection of fields such as `ID`, `Organization`, `Name`, and `CustomFields`.
By default, a set of fields will be returned for all selected GraphQL `OBJECT` type fields, such as `Organization` and `CustomFields`.

```csharp
DataList<Person> people = await client.Get(Query.Person
.Select(PersonField.ID, PersonField.Name)
.SelectOrganization(new OrganizationQuery()
.Select(OrganizationField.ID, OrganizationField.Name, OrganizationField.Disabled)));
```

To further refine the selection of fields by using a query for a specific GraphQL `OBJECT` type field, in this case, `Organization`.
By using the `SelectOrganization` method on the `Query.Person` object, you can specify the fields to include for the `Organization` field.
The example demonstrates the selection of fields like `ID`, `Name`, and `Disabled` for the `Organization` field.

##### All fields
```csharp
Expand Down
10 changes: 10 additions & 0 deletions Scr/Sdk4me.GraphQL/Queries/AccountQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,15 @@ public AccountQuery()
: base("account", typeof(Account), false)
{
}

/// <summary>
/// The organization for which the account was prepared.
/// </summary>
public AccountQuery SelectOrganization(OrganizationQuery query)
{
query.FieldName = "organization";
query.IsConnection = false;
return Select(query);
}
}
}
16 changes: 16 additions & 0 deletions Scr/Sdk4me.GraphQL/Queries/ActivityIDQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Sdk4me.GraphQL
{
/// <summary>
/// The <see cref="ActivityID">ActivityID</see> query.
/// </summary>
public class ActivityIDQuery : Query<ActivityIDQuery, ActivityIDField, DefaultView, DefaultOrderField>
{
/// <summary>
/// Initialize a new activity id query instance.
/// </summary>
public ActivityIDQuery()
: base("", typeof(ActivityID), false)
{
}
}
}
100 changes: 100 additions & 0 deletions Scr/Sdk4me.GraphQL/Queries/AffectedSlaQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,105 @@ public AffectedSlaQuery()
: base("affectedSlas", typeof(AffectedSla), true)
{
}

/// <summary>
/// The First line team field is automatically set to the team that, at the time the affected SLA was created, was selected in the First line team field of the related service instance.
/// </summary>
public AffectedSlaQuery SelectFirstLineTeam(TeamQuery query)
{
query.FieldName = "firstLineTeam";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// The Request field is automatically set to the request for which the affected SLA was generated.
/// </summary>
public AffectedSlaQuery SelectRequest(RequestQuery query)
{
query.FieldName = "request";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// If the impact of the affected SLA is "Top - Service Down for Several Users", the Service hours field is automatically set to the service hours calendar of the service offering of the related service level agreement.
/// </summary>
public AffectedSlaQuery SelectServiceHours(CalendarQuery query)
{
query.FieldName = "serviceHours";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// The Service instance field is automatically set to the Service Instance that, at the time the affected SLA was created, was selected in the Service instance field of the related service level agreement.
/// </summary>
public AffectedSlaQuery SelectServiceInstance(ServiceInstanceQuery query)
{
query.FieldName = "serviceInstance";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// The Service level agreement field is automatically set to the service level agreement that is considered affected.
/// </summary>
public AffectedSlaQuery SelectServiceLevelAgreement(ServiceLevelAgreementQuery query)
{
query.FieldName = "serviceLevelAgreement";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// The Standard service request field is automatically set to the standard service request that is linked to the service offering of the service level agreement and which response and resolution targets were used to calculate the <c>responseTargetAt</c> and <c>resolutionTargetAt</c> for the affected SLA.
/// </summary>
public AffectedSlaQuery SelectStandardServiceRequest(StandardServiceRequestQuery query)
{
query.FieldName = "standardServiceRequest";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// A list of time periods between which the clock was stopped for this affected SLA.
/// </summary>
public AffectedSlaQuery SelectStoppedClockPeriods(PeriodQuery query)
{
query.FieldName = "stoppedClockPeriods";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// The Supplier field is automatically set to the Organization that, at the time the affected SLA was created, was selected in the Service provider field of the related service instance. This field is only filled out, however, if this service provider is an external organization.
/// </summary>
public AffectedSlaQuery SelectSupplier(OrganizationQuery query)
{
query.FieldName = "supplier";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// The Support hours field is automatically set to the support hours Calendar that was selected for the impact level specified above in the service offering of the related service level agreement.
/// </summary>
public AffectedSlaQuery SelectSupportHours(CalendarQuery query)
{
query.FieldName = "supportHours";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// The Support team field is automatically set to the team that, at the time the affected SLA was created, was selected in the Support team field of the related service instance.
/// </summary>
public AffectedSlaQuery SelectSupportTeam(TeamQuery query)
{
query.FieldName = "supportTeam";
query.IsConnection = false;
return Select(query);
}
}
}
40 changes: 40 additions & 0 deletions Scr/Sdk4me.GraphQL/Queries/AgileBoardColumnQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ public AgileBoardColumnQuery()
{
}

/// <summary>
/// The account this record belongs to.
/// </summary>
public AgileBoardColumnQuery SelectAccount(AccountQuery query)
{
query.FieldName = "account";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// Agile board the column is part of.
/// </summary>
public AgileBoardColumnQuery SelectAgileBoard(AgileBoardQuery query)
{
query.FieldName = "agileBoard";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// Items in this column.
/// </summary>
Expand All @@ -21,5 +41,25 @@ public AgileBoardColumnQuery SelectItems(AgileBoardItemQuery query)
query.FieldName = "items";
return Select(query);
}

/// <summary>
/// Person to assign the item to when action type is <c>assign</c> and an item is added to this column.
/// </summary>
public AgileBoardColumnQuery SelectMember(PersonQuery query)
{
query.FieldName = "member";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// Team to assign the item to when action type is <c>assign</c> and an item is added to this column.
/// </summary>
public AgileBoardColumnQuery SelectTeam(TeamQuery query)
{
query.FieldName = "team";
query.IsConnection = false;
return Select(query);
}
}
}
20 changes: 20 additions & 0 deletions Scr/Sdk4me.GraphQL/Queries/AgileBoardItemQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,25 @@ public AgileBoardItemQuery()
: base("", typeof(AgileBoardItem), true)
{
}

/// <summary>
/// Board this item is placed on.
/// </summary>
public AgileBoardItemQuery SelectAgileBoard(AgileBoardQuery query)
{
query.FieldName = "agileBoard";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// Column this item is placed in.
/// </summary>
public AgileBoardItemQuery SelectAgileBoardColumn(AgileBoardColumnQuery query)
{
query.FieldName = "agileBoardColumn";
query.IsConnection = false;
return Select(query);
}
}
}
30 changes: 30 additions & 0 deletions Scr/Sdk4me.GraphQL/Queries/AgileBoardQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ public AgileBoardQuery()
{
}

/// <summary>
/// The account this record belongs to.
/// </summary>
public AgileBoardQuery SelectAccount(AccountQuery query)
{
query.FieldName = "account";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// Columns of this agile board.
/// </summary>
Expand All @@ -22,6 +32,16 @@ public AgileBoardQuery SelectColumns(AgileBoardColumnQuery query)
return Select(query);
}

/// <summary>
/// Scrum sprint the agile board is currently linked to.
/// </summary>
public AgileBoardQuery SelectCurrentSprint(SprintQuery query)
{
query.FieldName = "currentSprint";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// Files and inline images linked to the Description field.
/// </summary>
Expand All @@ -30,5 +50,15 @@ public AgileBoardQuery SelectDescriptionAttachments(AttachmentQuery query)
query.FieldName = "descriptionAttachments";
return Select(query);
}

/// <summary>
/// Manager of the agile board.
/// </summary>
public AgileBoardQuery SelectManager(PersonQuery query)
{
query.FieldName = "manager";
query.IsConnection = false;
return Select(query);
}
}
}
72 changes: 71 additions & 1 deletion Scr/Sdk4me.GraphQL/Queries/AppInstanceQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ public AppInstanceQuery()
{
}

/// <summary>
/// The account this record belongs to.
/// </summary>
public AppInstanceQuery SelectAccount(AccountQuery query)
{
query.FieldName = "account";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// App offering (version) this instance is at.
/// </summary>
public AppInstanceQuery SelectAppOffering(AppOfferingQuery query)
{
query.FieldName = "appOffering";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// Automation rules of this instance.
/// </summary>
Expand All @@ -22,6 +42,16 @@ public AppInstanceQuery SelectAutomationRules(AutomationRuleQuery query)
return Select(query);
}

/// <summary>
/// Values of custom fields.
/// </summary>
public AppInstanceQuery SelectCustomFields(CustomFieldQuery query)
{
query.FieldName = "customFields";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// Inline images linked to one of the custom fields.
/// </summary>
Expand All @@ -31,6 +61,46 @@ public AppInstanceQuery SelectCustomFieldsAttachments(AttachmentQuery query)
return Select(query);
}

/// <summary>
/// Account this app instance is for.
/// </summary>
public AppInstanceQuery SelectCustomerAccount(AccountQuery query)
{
query.FieldName = "customerAccount";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// Contact person of customer regarding this app instance.
/// </summary>
public AppInstanceQuery SelectCustomerRepresentative(PersonQuery query)
{
query.FieldName = "customerRepresentative";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// Webhook of this app instance.
/// </summary>
public AppInstanceQuery SelectWebhook(WebhookQuery query)
{
query.FieldName = "webhook";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// The current policy used for the instance's webhook.
/// </summary>
public AppInstanceQuery SelectWebhookPolicy(WebhookPolicyQuery query)
{
query.FieldName = "webhookPolicy";
query.IsConnection = false;
return Select(query);
}

/// <summary>
/// <br>Filter the 'AppInstance' by their custom fields that have been marked as 'Filterable' in their UI Extension.</br>
/// <br>Additional information is available on the <see href="https://developer.4me.com/graphql/input_object/appinstancecustomfilter/">4me developer site</see>.</br>
Expand Down Expand Up @@ -63,7 +133,7 @@ public AppInstanceQuery SelectCustomFieldsAttachments(AttachmentQuery query)
/// <br>• Matches are case-sensitive.</br>
/// </param>
/// <exception cref="NullReferenceException"></exception>
public AppInstanceQuery CustomFilter(string name, FilterOperator filterOperator, params string[] values)
public AppInstanceQuery CustomFilter(string name, FilterOperator filterOperator, params string?[] values)
{
return AddCustomFilter(name, filterOperator, values);
}
Expand Down
Loading

0 comments on commit 0352b7b

Please sign in to comment.