Skip to content

Improved endpoint function typing and readme#318

Merged
Jesperholmbergmsft merged 1 commit into
microsoft:mainfrom
Jesperholmbergmsft:jh/endpointTypingTweaks
Aug 28, 2025
Merged

Improved endpoint function typing and readme#318
Jesperholmbergmsft merged 1 commit into
microsoft:mainfrom
Jesperholmbergmsft:jh/endpointTypingTweaks

Conversation

@Jesperholmbergmsft

Copy link
Copy Markdown
Contributor

This PR improves the endpoint functions to not generate body & parameter arguments for APIs that don't need them. This reduces type clutter a little, and avoids generating impossible signatures.

For instance, POST /me/reprocessLicenseAssignment was generated with this effective signature:
function create(body: never, params?: {} | undefined) : whatever

This API doesn't take any body or params at all, so the types.ts requestBody type for this API is 'never'. Our code has assumed that all non-get, non-delete APIs will always require a body however, so we've been happily generating the body argument. The result is that body: never argument - which is problematic as there's nothing I can pass to satisfy it.

The empty params type is not problematic as such, but it's a bit of clutter.

To make this PR reviewable, I only re-generated a handful of endpoints to show the difference before/after the changes. and keep the PR readable I'm planning to re-generate everything next week and that'll propagate the fixes.

Other minor things

  • paramDefs are made optional in the EndpointRequest type, to match params and reduce clutter
  • the EndpointRequest and CallOptions types are exported out of the Graph client, to make it easier to make custom endpoint functions.
  • the graph-endpoints and graph-endpoints-beta readmes are updated to correct links & instructions.

@Jesperholmbergmsft
Jesperholmbergmsft marked this pull request as ready for review August 27, 2025 16:45
Comment thread packages/graph-endpoints/src/me/appRoleAssignments.ts
Comment thread packages/graph-endpoints/src/me/removeAllDevicesFromManagement.ts
Comment thread packages/graph-endpoints/src/types/common.ts
Comment thread packages/graph-tools/src/endpoints.ts
@Jesperholmbergmsft
Jesperholmbergmsft merged commit 6c8e79d into microsoft:main Aug 28, 2025
5 checks passed
Copilot AI added a commit that referenced this pull request Feb 11, 2026
- Move isTargeted from MessageActivity to base Activity class as non-nullable boolean
- Update withRecipient in Activity to accept optional isTargeted parameter
- Override withRecipient in MessageActivity to maintain return type
- Remove withTargetedRecipient method from MessageActivity
- Update all examples and tests to use new API pattern
- Update validation error messages
- Add isTargeted property to devtools feedback activity

Co-authored-by: rido-min <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants