You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-5Lines changed: 20 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,20 @@ This is a CosmosDB DataSource for the Apollo GraphQL Server. It was adapted from
4
4
5
5
## Usage
6
6
7
-
Use by creating a new class, inheriting from `CosmsosDataSource` passing in the CosmosDb container instance (created from the CosmosDB Javascript API)
7
+
Use by creating a new class, inheriting from `CosmsosDataSource` passing in the CosmosDb container instance (created from the CosmosDB Javascript API). Use a separate DataSource for each data type.
8
+
9
+
Example:
8
10
9
11
`data-sources/Users.ts`
10
12
11
13
```typescript
14
+
exportinterfaceUserDoc {
15
+
id:string; // a string id value is required for entities using this library
CosmosDataSource exposes a `findManyByQuery` method that accepts a ComosDB SQL query either as a string or a `SqlQuerySpec` object containing the query and a parameter collection. This can be used direclty in the resolvers, but probably better to create wrappers that hide the query details:
50
+
CosmosDataSource exposes a `findManyByQuery` method that accepts a ComosDB SQL query either as a string or a `SqlQuerySpec` object containing the query and a parameter collection. This can be used direclty in the resolvers, but probably better to create wrappers that hide the query details.
51
+
52
+
Creating a derived class with custom query methods, you can hide all of your query logic in the DataSource class:
The data loader (and cache, if used) are updated after mutation operations.
@@ -91,12 +107,11 @@ Caching is available on an opt-in basis by passing a `ttl` option on queries.
91
107
92
108
## Typescript
93
109
94
-
This library is written in Typescript and exports full type definitions, but usable in pure Javascript as well.
110
+
This library is written in Typescript and exports full type definitions, but usable in pure Javascript as well. This works really well with [GraphQL Codegen's typed resolvers](https://the-guild.dev/blog/better-type-safety-for-resolvers-with-graphql-codegen).
0 commit comments