-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
add yaml support to apollo-client #1944
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1944 +/- ##
===========================================
+ Coverage 50.26% 50.86% +0.6%
- Complexity 1927 1979 +52
===========================================
Files 396 398 +2
Lines 12040 12175 +135
Branches 1224 1249 +25
===========================================
+ Hits 6052 6193 +141
+ Misses 5534 5524 -10
- Partials 454 458 +4
Continue to review full report at Codecov.
|
63e003b
to
532fa48
Compare
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.
LGTM and I left a comment for your information
/** | ||
* @return the properties form of the config file or an empty properties if the content is invalid | ||
*/ | ||
Properties asProperties(); |
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.
Is it really good to return an empty properties
(instead of throwing) in case of the content is invalid? Then how do we tell that whether the content is empty or invalid. Isn't there such a situation that we need to do that?
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.
This is really a good question!
I think we need to give some thoughts into this...
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.
My thought was throwing some exceptions like MalformedYamlException
in case where the YAML document is invalid and returning empty properties
in case where the YAML document is 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.
I think you are right, so asProperties
will now throw a runtime exception if the content cannot be transformed to properties
1. support yaml config file transform to properties 2. support yaml config file injection to Spring
532fa48
to
b1ca961
Compare
Fixes #653, #1113, #1321, #1488, #1585, #1698,
Usage
Suppose you have a yml format namespace called 'application.yaml' as the following screenshot, then we could retrieve or inject the config just as the properties format in several ways.
1. API Usage
2. Spring Injection Usage
2.1 XML Config
2.2 Java Config
3. Spring Boot Injection Usage
application.properties/bootstrap.properties content: