Skip to content

Is it really correct that the Javascript version of the graph SDK doesn't offer typed requests? #2004

Description

@catmanjan

I'm coming from a C# background so forgive me if I'm wrong on this, but from the documentation it seems for example that doing a graph search in C# is fully typed, e.g:


var requestBody = new QueryPostRequestBody
{
Requests = new List<SearchRequest>
{
new SearchRequest
{
EntityTypes = new List<EntityType?>
{
EntityType.ExternalItem,
},
ContentSources = new List<string>
{
"/external/connections/connectionfriendlyname",
},
Region = "US",
Query = new SearchQuery
{
QueryString = "contoso product",
},
From = 0,
Size = 25,
Fields = new List<string>
{
"title",
"description",
},
},
},
};
var result = await graphClient.Search.Query.PostAsQueryPostResponseAsync(requestBody);

Which is fine, give you a SearchResponse object.

whereas in javascript you need to use the "magic string" /search/query for example:


const searchResponse = {
requests: [
{
entityTypes: [
'externalItem'
],
contentSources: [
'/external/connections/connectionfriendlyname'
],
region: 'US',
query: {
queryString: 'contoso product'
},
from: 0,
size: 25,
fields: [
'title',
'description'
]
}
]
};
await client.api('/search/query')
.post(searchResponse);

And this returns an any type, so you have to know/guess the response?

Both samples taken from https://learn.microsoft.com/en-us/graph/api/search-query?view=graph-rest-1.0&utm_source=chatgpt.com&tabs=javascript

Is this actually correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions