-
Notifications
You must be signed in to change notification settings - Fork 232
GraphClientsDesign.md #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
9d92a7b
1b4bcbb
612d9b2
2fe5322
d8f6f7f
f5545d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
### Graph JS Deliverables: | ||
|
||
Note: Package names yet to be decided. The names are just examples and `service` and `core` prefix in the package names are for clarity purposes. | ||
|
||
1. `microsoftgraph/microsoft-graph-javascript-service`: | ||
|
||
- Generated library which the request builders. Generated using Kiota builder. | ||
|
||
- Will have dependencies on : | ||
- @microsoftgraph/microsoft-graph-javascript-core | ||
- @microsoft/kiota-abstractions | ||
- @microsoft/kiota-http-fetchlibrary | ||
- @microsoft/kiota-serialization-json | ||
|
||
2. `microsoftgraph/microsoft-graph-javascript-core`: | ||
|
||
- Contains Graph customizations and tasks such as PageIteration, LargeFileUpload. | ||
|
||
- Will have dependencies on : | ||
- @microsoft/kiota-abstractions | ||
- @microsoft/kiota-http-fetchlibrary | ||
|
||
### Usage of the two libraries : | ||
|
||
As mentioned in PR: #558 | ||
|
||
Also, tasks constructors such as `PageIterator` and `LargeFileUpload` tasks should accept both `GraphServiceClient` and `GraphCoreClient` | ||
|
||
``` | ||
// both should work | ||
const pageIterator = PageIterator(GraphServiceClient, options); | ||
or | ||
const pageIterator = PageIterator(GraphCoreClient, options); | ||
``` | ||
|
||
Goals: | ||
|
||
- A Graph JS SDK user should not be required to create separate client instances for Graph Service library or the Graph Core library. | ||
- To achieve this, the `Graph Service Client` should also expose the features of `Graph Core Client`. | ||
|
||
Design: | ||
|
||
1. `Graph Service client` should extend from `Graph Core Client`: | ||
|
||
``` | ||
|
||
import { Client as GraphCoreClient } from `@microsoft/microsoft-graph-javascript-core`; | ||
|
||
|
||
class GraphServiceClient extends GraphCoreClient { | ||
|
||
public api(){ | ||
super.api(); | ||
} | ||
} | ||
|
||
``` | ||
|
||
- To acheive the above design we will need to customize the auto-generated `GraphServiceClient`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could achieve that by adding the API method to a base request adapter in the core repo. This way your code doesn't need to be duplicated between v1 and beta There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this mean exactly? How extensible is the base request adapter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it doesn't exist yet, but this is how I handled it in Go. kiota defines an http request adapter. Go core a BaseGraphRequestAdapter, which adds a bit of customization for graph on top of kiota. In this case the customization could be the API method to allow execution of arbitrary requests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following are reasons to use an inheritance:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my point being that the page iterator doesn't need the client but just the request adapter to be able to execute requests. You could use the RequestAdapter property on the client, like the dotnet implementation, but I believe this will change to use the request adapter straight away because of the inheritance limitation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @baywet, what would look like a call using the request adapter. Do we really want the complexity to land of the developer? Is that even complex? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const pageIterator = PageIterator(GraphServiceClient.requestAdapter, options); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Even with the
I can see the value of a extending the GraphRequestAdapter in the Graph SDKs which will allow extensibility and easy customization. This should be plugged in optimally. |
||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.