Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions spec/core/urlGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ cases.push({
.select("jobTitle")
});

cases.push({
url: "https://graph.microsoft.com/v1.0/me?$select=displayName,jobTitle",
request: client.api("/me")
.select("displayName", "jobTitle")
});

cases.push({
url: "https://graph.microsoft.com/beta/me?$select=displayName,jobTitle",
request: client.api("/me")
Expand Down
16 changes: 11 additions & 5 deletions src/GraphRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class GraphRequest {
}


private urlJoin(urlSegments:[string]):String {
private urlJoin(urlSegments:string[]):String {
const tr = (s) => s.replace(/\/+$/, '');
const tl = (s) => s.replace(/^\/+/, '');
const joiner = (pre, cur) => [tr(pre), tl(cur)].join('/');
Expand Down Expand Up @@ -127,17 +127,23 @@ export class GraphRequest {
* and .select("displayName", "birthday")
*
*/
select(properties:string|[string]):GraphRequest {
select(properties: string[]):GraphRequest
select(properties: string, ...additionalProperties: string[]):GraphRequest
select(properties:string|string[]):GraphRequest {
this.addCsvQueryParamater("$select", properties, arguments);
return this;
}

expand(properties:string|[string]):GraphRequest {
expand(properties: string[]):GraphRequest
expand(properties: string, ...additionalProperties: string[]):GraphRequest
expand(properties:string|string[]):GraphRequest {
this.addCsvQueryParamater("$expand", properties, arguments);
return this;
}

orderby(properties:string|[string]):GraphRequest {
orderby(properties: string[]):GraphRequest
orderby(properties: string, ...additionalProperties: string[]):GraphRequest
orderby(properties:string|string[]):GraphRequest {
this.addCsvQueryParamater("$orderby", properties, arguments);
return this;
}
Expand Down Expand Up @@ -174,7 +180,7 @@ export class GraphRequest {
}

// helper for $select, $expand and $orderby (must be comma separated)
private addCsvQueryParamater(propertyName:string, propertyValue:string|[string], additionalProperties:IArguments) {
private addCsvQueryParamater(propertyName:string, propertyValue:string|string[], additionalProperties:IArguments) {
// if there are already $propertyName value there, append a ","
this.urlComponents.oDataQueryParams[propertyName] = this.urlComponents.oDataQueryParams[propertyName] ? this.urlComponents.oDataQueryParams[propertyName] + "," : "";

Expand Down