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

Offen
#2,004 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
42/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig

Rechercherichtung

Start with the JavaScript tab in the linked Microsoft Graph search-query documentation and inspect the client.api('/search/query') request and response behavior. Compare that with the typed C# sample; done means establishing whether typed request and response support exists in this SDK and documenting or scoping the gap clearly.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

status:waiting-for-triage

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?

Vorherrschende Sprache
TypeScript
Sterne
833
Forks
240
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microsoftgraph/msgraph-sdk-javascript

Alle Issues in microsoftgraph/msgraph-sdk-javascript

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.