Skip to content

Commit

Permalink
docs(blue-api-sdk): update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Jul 29, 2024
1 parent ccff01f commit 84c89d9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
57 changes: 51 additions & 6 deletions packages/blue-api-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,72 @@ yarn add @morpho-org/blue-api-sdk

## Getting Started


### Codegen

Create a `codegen.ts` file using the [near-operation-file](https://the-guild.dev/graphql/codegen/plugins/presets/near-operation-file-preset) preset and define your desired plugins:
Create a `codegen.ts` file and define your desired preset & plugins, importing types from `@morpho-org/blue-api-sdk`. Below is given 3 typically recommended configurations:

#### Recommended [near-operation-file](https://the-guild.dev/graphql/codegen/plugins/presets/near-operation-file-preset) preset config

```typescript
import type { CodegenConfig } from "@graphql-codegen/cli";

import { BLUE_API_GRAPHQL_URL } from "@morpho-org/morpho-ts";

const config: CodegenConfig = {
overwrite: true,
...,
schema: BLUE_API_GRAPHQL_URL,
documents: ["src/graphql/**/*.query.gql", "src/graphql/**/*.fragment.gql"],
documents: ["src/graphql/**/*.{query,fragment}.gql"],
generates: {
"src/graphql/": {
...,
preset: "near-operation-file",
plugins: ["typescript-operations", "typescript-react-apollo"],
presetConfig: {
baseTypesPath: "~@morpho-org/blue-api-sdk",
},
},
},
};

export default config;
```

#### Recommended [import-types](https://the-guild.dev/graphql/codegen/plugins/presets/import-types-preset) preset config

```typescript
import type { CodegenConfig } from "@graphql-codegen/cli";

import { BLUE_API_GRAPHQL_URL } from "@morpho-org/morpho-ts";

const config: CodegenConfig = {
...,
schema: BLUE_API_GRAPHQL_URL,
documents: ["graphql/*.{query,fragment}.gql"],
generates: {
"src/api/types.ts": {
...,
preset: "import-types",
presetConfig: {
typesPath: "@morpho-org/blue-api-sdk",
},
},
},
};
```

#### Recommended [typescript-operations](https://the-guild.dev/graphql/codegen/plugins/typescript-operations) plugin config

```typescript
import type { CodegenConfig } from "@graphql-codegen/cli";

import { BLUE_API_GRAPHQL_URL } from "@morpho-org/morpho-ts";

const config: CodegenConfig = {
...,
schema: BLUE_API_GRAPHQL_URL,
generates: {
[...]: {
plugins: ["typescript-operations", ...],
config: {
avoidOptionals: {
field: true,
Expand Down Expand Up @@ -67,10 +113,9 @@ const config: CodegenConfig = {
},
},
};

export default config;
```


### Apollo

Define an Apollo cache to use and specify the cache type policies exported from this package:
Expand Down
2 changes: 1 addition & 1 deletion packages/blue-api-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@morpho-org/blue-api-sdk",
"version": "1.1.0",
"version": "1.1.1",
"author": "Morpho Association <[email protected]>",
"main": "src/index.ts",
"files": [
Expand Down

0 comments on commit 84c89d9

Please sign in to comment.