-
Notifications
You must be signed in to change notification settings - Fork 3
Add HttpClientFactory and update Graph client to use it #2
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
Conversation
|
Sorry about lots of whitespace changes. Trying to get that sorted. |
| * @link https://developer.microsoft.com/graph | ||
| */ | ||
| class ClientInitialisationException extends GraphException | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It extends all functionality of the GraphException with nothing custom to add.
Thanks for pointing out a bug though, I need to change GraphException's __toString() to print the child class name where needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of GraphException class?
For the JS SDK, @MIchaelMainer had suggested creating a GraphCientError class which handles the errors such as ClientInitialisationException and a GraphError class which handles errors from the API.
I would suggest using something similar because:
- There is a sync in the SDKs
- Avoid creating an empty class if you are not extending or adding more functionalities.
- A generic GraphClientError class with clear messages reduces the need to create multiple class depending on the feature. For example, ClientInitialization, an error class for PageIteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for catching this! We still need to better define our error classification. At a high-level, we have two primary exceptions: ServiceException that represents errors returned in an API response and ClientException for issues raised in the client. Both of these can extend GraphException.
I just created a quick PR to help us be more consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated ClientInitialisationException to GraphClientException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ndiritu Graph Exception that is the parent class is it the service exception class?
What is the class which captures the Graph API error response?
If GraphException is the service error response class then I recommend you to keep them separate as mentioned by @MIchaelMainer in the PR microsoftgraph/msgraph-sdk-design#47
I suppose you can address this in a separate PR focusing on the error classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikithauc Yes, i'll need to make these changes in a separate PR.
|
Thanks for the thought-provoking feedback @nikithauc! I've addressed all issues/comments raised. |
Thanks for addressing the issues!! Appreciate your efforts in improving the core library. |
…hanges Remove Guzzle specific config and methods from Graph request classes
Changes that differ from initial design doc
apiVersion()in the HttpClientFactory since setting the base URL tohttps://[national cloud]/[apiVersion]would mean customers need to pass and endpoint without a leading/for the correct URL to be resolved by Guzzle. Our docs provide endpoints with the leading/. Api version will be appended to nationalCloud in the GraphRequest before sending itGuzzle plans to deprecate functionality (
getConfig()) that would allow us to get the config array that was used to initialise a client in Guzzle 8. Impact is, if the SDK accepts a Guzzle client object, we would be unable to set default configs while preserving any custom configs the customer may have used.FYI
Thought it would be easier to have this PR first to show the
HttpClientFactoryand its integration into theGraphclient.To reduce the number of changes per PR, I'll create other branches off
philip/feat/http-client-factorywith changes to other classes that are affected by this feature -GraphRequest, various failing tests etc.Once this PR is approved, the other PRs will be merged into the current branch before merging to main.
Note: Tests currently failing. Will be fixed in subsequent "child" branches of the current branch then merged.
Closes https://github.com/microsoftgraph/msgraph-sdk-php/issues/438
Closes microsoftgraph/msgraph-sdk-php#531