Commit e210fb2
Dev/seleonar/incr metadata client providers (#12)
* Merged PR 649012: Generalize ClientProvider, ConfigurationProvider, and DB Connection Configuration
Introducing changes to abstract out DatabaseCredentials, ClientProvider with changes to accomodate this in the ConfigurationProvider and Startup classes. Configuration files updated to accommodate interpreting database type during startup and configuration initialization.
# Why this change is needed
The first step in extending the POC to be compatible with SQL Database is through generalizing the database credentials classes, the clientproviders, and configuration provider.
# How
Describe how the change works.
##Startup class
- Infers DatabaseType from _appsettings.json_ . The DatabaseType determines the implementation of _IClientProvider_.
##IDatabaseCredentials interface
- created to capture overlap between SQL and Cosmos connections which is the ConnectionString.
I chose _ConnectionString_ over _EndpointURL_ as the interface member because connectionstring is a superset of endpointurl for both database types. Can leave database specific details such as username, password, access keys to the specific class implementations. Future work to accommodate Postgres TBD because Postgres requires connectionstring to be built.
##IClientProvider interface
- Created to capture overlap between clients. ClientProvider class must implement getClient(). Client initialization adhering to initial Cosmos POC model of Singletons.
- Generic interface types expected:
- SQL: SqlConnection
- Cosmos: CosmosClient
- Current PR utilizes Cosmos implementation of Singleton for connection. I want to get E2E working here first before optimizing further for collection of connections, which is implemented in SQLREST project.
##ConfigurationProvider
- On initialization, the instance (Singleton enforced) reads from _appsettings.json_ to determine which DbCredential to create.
##Appsettings.json
- Added proposed new db configuration structure to be read in by the configuration provider and startup class. The config specifies the database type to instruct which credentials class to implement (SQL/Cosmos).
- Specific credentials classes created to accommodate future need to build the connection string.
``` json
"DatabaseConnection": {
"DatabaseType": "COSMOS",
"Credentials": {
"ServerEndpointUrl": "",
"AuthorizationKey": "",
"Container": "",
"Database": "",
"ConnectionString": ""
}
}
```
# Test
Integration testing by calling REST endpoint to add and query schema.
Addition test class written for ClientProvider to validate opening SQL connection succeeds.
# Checklist
- [X] Build and run test locally.
- [ ] Check code coverage report and make sure that there are test coverage for your change.
- [X] Link work item to this change.
- [ ] Update the design/functional docs.
added README to the section on testing
Related work items: #1333552
* Merged PR 654028: Create FileMetadataStoreProvider to read GraphQL config from file
#Summary
Initial work to create FileMetadataStoreProvider, enables reading JSON config from file. Renamed interface to IMetadataStoreProvider. Sample Config.json for runtime config. Gitignore updated to ignore /vs folder. Added two simple integration tests for new fileprovider.
# Why this change is needed
The first step in extending the POC to be compatible with SQL Database is through generalizing the database credentials classes, the clientproviders, and configuration provider.
# How
Describe how the change works.
##IMetadataStoreProvider
- Files which had previously referenced the interface as MetadataStoreProvider now reference the renamed interface __IMetadataStoreProvider__
##FileMetadataStoreProvider
- Implemented to act us underlying storage of configuration data assuming that configuration is only read once at startup. In this case, the class constructor is responsible for reading the file, storing the GraphQL schema string and saving the Resolvers as key/value pairs into a collection. The Get() calls are similar to the cachedmetadatastoreprovider where a dictionary is used to keep track of resolvername:resolvervalue.
##config.json
- Added simplified skeleton of GraphQL configuration file as agreed on during architecture meetings: 1 file with schema and resolvers embedded
``` json
{
"GraphQLSchema": "",
"Resolvers": [
{
"engine": "SQL",
"name": "bookById",
"database": "",
"container": "",
"parametrizedQuery": "SELECT * from r WHERE r.id = @arg.id",
"operationType": "READ_ITEM"
},
{
"name": "authorById"
}
]
}
```
##.gitignore
Updated to not track __vs/__ folders within the project, for sanity.
# Test
Integration testing done by creating MetadataProviderTests class:
- Getting schema from config
- Getting resolver from config
# Checklist
- [X] Build and run test locally.
- [X] Check code coverage report and make sure that there are test coverage for your change.
- [X] Link work item to this change.
- [ ] Update the design/functional docs.
added README to the section on testing
Related work items: #1333554
* Cherrypick FileMetadataProvider and SQL Client Provider + add classdiagram files for visualizing code.
* Removed unused IConfigurationProvider file
* Addressing PR comments. Renaming Sql references to MSSQL. Adding schema.gql file for development purposes with corresponding logic. Updated class summaries.
* Further updates to address comments. PascalCase db types, updated TestBase to pull relavant cosmos config for Query/Mutation simple tests. updated class summary spelling.
* PascalCase dbtype in appsettings.json
* Removed class diagrams. Added vscode related configuration to correctly run. Also removed implementation/demo specific config.json values. Updated gitignore to not track bin and obj directories.
Co-authored-by: Sean Leonard <[email protected]>1 parent 3a62c56 commit e210fb2
File tree
27 files changed
+505
-76
lines changed- Cosmos.GraphQL.Service
- Cosmos.GraphQL.Service.Tests
- Cosmos.GraphQL.Service
- .vscode
- Resolvers
- Services
- configurations
27 files changed
+505
-76
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | | - | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
7 | 17 | | |
8 | 18 | | |
9 | 19 | | |
10 | 20 | | |
11 | 21 | | |
12 | 22 | | |
| 23 | + | |
13 | 24 | | |
14 | 25 | | |
| 26 | + | |
| 27 | + | |
15 | 28 | | |
16 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
17 | 33 | | |
18 | 34 | | |
Lines changed: 8 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | | - | |
18 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | | - | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | 39 | | |
44 | 40 | | |
45 | 41 | | |
0 commit comments