microsoft-graph-toolkit icon indicating copy to clipboard operation
microsoft-graph-toolkit copied to clipboard

New component: mgt-post

Open waldekmastykarz opened this issue 3 years ago • 8 comments

Proposal: New component: mgt-post

Description

Add a new component (mgt-post) that allows you to post data to Microsoft Graph APIs

Rationale

A generic Post component would enable many scenarios powered by Microsoft Graph, such as creating to do items, scheduling meetings, creating list items, uploading files, etc. Having an MGT component that does this, would simplify communication with Graph and let developers focus on building the UI.

Preferred Solution

Properties

Attribute Property Description
endpoint endpoint The endpoint to submit the data to
scopes scopes Optional array of strings if using the property or a comma delimited scope if using the attribute. The component will use these scopes (with a supported provider) to ensure that the user has consented to the right permission.
version version Optional API version to use when making the request. Default is v1.0.
N/A data Data to send to Microsoft Graph. Must match the payload required by the API specified in the endpoint property
N/A response Read-only response from Microsoft Graph if request was successful.
N/A error Read-only error from Microsoft Graph if request was not successful.

Events

  • submit: occurs when submitting the form. Details contain the template from which developers can extract user input to submit to Graph. During this event developers should extract the data from the UI, validate it and assign to the data property which will be used by the Post component to submit it to Graph. Cancelable.

Templates

  • default: default template to render the initial UI
  • submitting: UI to render while submitting the data to Graph
  • submitted: UI to render after submitting the data to Graph. If not specified, renders the default UI
  • error: UI to render if submitting the data to Graph failed. If not specified, renders the default UI

Additional Context

For simplicity, we could start with the Post component supporting posting only JSON data. Later, we could extend it with support for uploading files as well as other update methods like PATCH or PUT.

Should we have support for validating the data before submitting it (eg. a separate validate event that occurs before the submit event) or would we rather have developers perform validation inside the submit event and cancel it if the validation failed?

waldekmastykarz avatar Jun 30 '21 08:06 waldekmastykarz