Skip to content

Commit

Permalink
Improve documentation (#180)
Browse files Browse the repository at this point in the history
* Start simplifying docs

* Improve documentation
  • Loading branch information
samdenty authored Apr 14, 2021
1 parent 051bb9e commit af6a437
Show file tree
Hide file tree
Showing 155 changed files with 2,781 additions and 3,108 deletions.
17 changes: 17 additions & 0 deletions .changeset/fluffy-shrimps-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'github-example': patch
'mercurius-example': patch
'react-example': patch
'test-utils': patch
'website': patch
'@gqless/cli': patch
'gqless': patch
'@gqless/logger': patch
'@gqless/react': patch
'@gqless/subscriptions': patch
---

- Rename `GqlessConfig` to `GQlessConfig` (so it's consistent with the new logo)
- Rename `gqlessError` to `GQlessError`
- Remove `endpoint` option from the configuration, and instead always defaults to introspection one
- It's confusing why theres two of them, and the user can change it later by modifying the file anyway
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
<a href="https://gqless.com">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-documentation?color=C00B84">
</a>
<a href="https://discord.gg/9DNNPedhbx">
<img alt="Discord" src="https://img.shields.io/discord/793628688439836694?color=7289d9&label=discord">
</a>
<a href="https://twitter.com/gqlessdev">
<img alt="Twitter" src="https://img.shields.io/twitter/follow/gqlessdev?label=%40gqlessdev&style=flat&logo=twitter&color=00acee">
</a>
Expand Down
30 changes: 0 additions & 30 deletions docs/FAQ.mdx

This file was deleted.

4 changes: 2 additions & 2 deletions docs/cli/codegen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ export * from './schema.generated';

You can modify this file safely, and each client has configurations you can set.

- See [Core client configuration](/core/config)
- See [Core client configuration](/client/config)

- See [React configuration](/react/config)

- See [Subscriptions configuration](/core/subscriptions)
- See [Subscriptions configuration](/client/subscriptions)
8 changes: 4 additions & 4 deletions docs/cli/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ The `CLI` looks for 3 places of configuration files/property, in this respective
2. `gqless.config.js`
3. `gqless` property inside `package.json`

And since it's using [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) to resolve it, if you are using `gqless` in a monorepo, having it in the root of your monorepo might be enough :tada:.
And since it's using [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) to resolve it, if you are using GQless in a monorepo, having it in the root of your monorepo might be enough :tada:.

## Default Config

The default configuration file, which is automatically generated after the first execution of `gqless generate`, should look like this:

```js
/**
* @type {import("@gqless/cli").GqlessConfig}
* @type {import("@gqless/cli").GQlessConfig}
*/
const config = {
endpoint: '/api/graphql',
Expand All @@ -43,13 +43,13 @@ module.exports = config;
| ---------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| endpoint | `string` | Endpoint used in the first-generated client, you are free to change it in there, and this config will be ignored. |
| enumsAsStrings | `boolean` | Whether to use enums as simple string types, or as the default [Object String Enums of TypeScript](https://www.typescriptlang.org/docs/handbook/enums.html#string-enums). |
| react | `boolean` | Whether to add the [React](/react/basic-usage) bindings to the first-generated client. |
| react | `boolean` | Whether to add the [React](/react/fetching-data) bindings to the first-generated client. |
| scalars | `Record<string,string>` | Mapping of Custom Scalar Types to TypeScript, since by default, **any custom scalar will be casted as `any`**. |
| preImport | `string` | Code to be added at the very beginning of the generated `schema file`, useful for adding custom imported types in custom scalars. |
| introspection.endpoint | `string` | Endpoint from where the introspection of the target GraphQL API, it can be an `http`/`https` endpoint, or the path of a `.gql` GraphQL schema file. |
| introspection.headers | `Record<string,string>` | Custom headers to be added to `http`/`https` introspection, normally for authorization purposes. |
| destination | `string` | **File destination** of the generated client. Keep in mind that the generated schema always will be alongside this destination, but named `schema.generated.ts`. |
| subscriptions | `boolean` | Whether to add [Subscriptions](/core/subscriptions) support to the client. |
| subscriptions | `boolean` | Whether to add [Subscriptions](/client/subscriptions) support to the client. |

---

Expand Down
6 changes: 3 additions & 3 deletions docs/cli/javascript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ id: javascript
title: JavaScript Output
---

Although the focus of `gqless` is to be used in [TypeScript](https://www.typescriptlang.org/),
Although the focus of GQless is to be used in [TypeScript](https://www.typescriptlang.org/),
it's completely possible to use it in JavaScript projects, outputting valid JavaScript code,
alongside it's type-definitions, and using [JSDoc](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html)
to be able to use a typed `gqless`.
to be able to use a typed GQless.

We recommend taking a look at [Type Checking JavaScript files](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html), [allowJs](https://www.typescriptlang.org/tsconfig#allowJs) and [checkJs](https://www.typescriptlang.org/tsconfig#checkJs).

Expand All @@ -16,7 +16,7 @@ To enable `JavaScript Output` you have to especify an extra `javascriptOutput` p

```js
/**
* @type {import("@gqless/cli").GqlessConfig}
* @type {import("@gqless/cli").GQlessConfig}
*/
const config = {
// It should be set as 'true' or removed.
Expand Down
10 changes: 5 additions & 5 deletions docs/cli/programmatic.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
id: programmatic
title: CLI Programmatic usage
title: Programmatic usage of CLI
sidebar_label: Programmatic usage
---

**@gqless/cli** has also a complete programmatic API, which allows you to generate the client with custom scripts.

## inspectWriteGenerate
## `inspectWriteGenerate`

Basically calling CLI functionality programmatically.

Expand Down Expand Up @@ -34,7 +34,7 @@ await inspectWriteGenerate({
});
```

## writeGenerate
## `writeGenerate`

If you have direct access to the [GraphQLSchema](https://graphql.org/graphql-js/type/#graphqlschema) from [graphql-js](https://github.com/graphql/graphql-js), you can give it to this function and it will do the rest.

Expand Down Expand Up @@ -68,7 +68,7 @@ await writeGenerate(
);
```

## generate
## `generate`

If you have direct access to the [GraphQLSchema](https://graphql.org/graphql-js/type/#graphqlschema) from [graphql-js](https://github.com/graphql/graphql-js), you can give it to this function and it generates the code and simply return it.

Expand Down Expand Up @@ -101,7 +101,7 @@ const {
);
```

## getRemoteSchema
## `getRemoteSchema`

Inspect a remote GraphQL API

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ hide_title: true

**hasFetchSubscribers**: _boolean_= false

Defined in: [packages/gqless/src/Events/index.ts:32](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Events/index.ts#L32)
Defined in: [packages/gqless/src/Events/index.ts:32](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Events/index.ts#L32)

---

### onCacheChangeListeners

`Private` **onCacheChangeListeners**: _Set_<OnCacheChangeEventFn\>

Defined in: [packages/gqless/src/Events/index.ts:35](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Events/index.ts#L35)
Defined in: [packages/gqless/src/Events/index.ts:35](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Events/index.ts#L35)

---

### onFetchListeners

`Private` **onFetchListeners**: _Set_<OnFetchEventFn\>

Defined in: [packages/gqless/src/Events/index.ts:33](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Events/index.ts#L33)
Defined in: [packages/gqless/src/Events/index.ts:33](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Events/index.ts#L33)

## Methods

Expand All @@ -54,7 +54,7 @@ Defined in: [packages/gqless/src/Events/index.ts:33](https://github.com/gqless/g

**Returns:** () => _void_

Defined in: [packages/gqless/src/Events/index.ts:48](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Events/index.ts#L48)
Defined in: [packages/gqless/src/Events/index.ts:48](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Events/index.ts#L48)

---

Expand All @@ -70,7 +70,7 @@ Defined in: [packages/gqless/src/Events/index.ts:48](https://github.com/gqless/g

**Returns:** () => _void_

Defined in: [packages/gqless/src/Events/index.ts:58](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Events/index.ts#L58)
Defined in: [packages/gqless/src/Events/index.ts:58](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Events/index.ts#L58)

---

Expand All @@ -86,7 +86,7 @@ Defined in: [packages/gqless/src/Events/index.ts:58](https://github.com/gqless/g

**Returns:** _void_

Defined in: [packages/gqless/src/Events/index.ts:37](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Events/index.ts#L37)
Defined in: [packages/gqless/src/Events/index.ts:37](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Events/index.ts#L37)

---

Expand All @@ -103,4 +103,4 @@ Defined in: [packages/gqless/src/Events/index.ts:37](https://github.com/gqless/g

**Returns:** _void_

Defined in: [packages/gqless/src/Events/index.ts:41](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Events/index.ts#L41)
Defined in: [packages/gqless/src/Events/index.ts:41](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Events/index.ts#L41)
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
id: 'gqlesserror'
title: 'Class: gqlessError'
sidebar_label: 'gqlessError'
title: 'Class: GQlessError'
sidebar_label: 'GQlessError'
custom_edit_url: null
hide_title: true
---

# Class: gqlessError
# Class: GQlessError

## Hierarchy

- _Error_

**gqlessError**
**GQlessError**

## Constructors

### constructor

\+ **new gqlessError**(`message`: _string_, `__namedParameters?`: { `caller?`: Function ; `graphQLErrors?`: readonly _GraphQLError_[] ; `otherError?`: _unknown_ }): [_gqlessError_](gqlesserror.md)
\+ **new GQlessError**(`message`: _string_, `__namedParameters?`: { `caller?`: Function ; `graphQLErrors?`: readonly _GraphQLError_[] ; `otherError?`: _unknown_ }): [_GQlessError_](gqlesserror.md)

#### Parameters:

Expand All @@ -30,19 +30,19 @@ hide_title: true
| `__namedParameters.graphQLErrors?` | readonly _GraphQLError_[] | - |
| `__namedParameters.otherError?` | _unknown_ | - |

**Returns:** [_gqlessError_](gqlesserror.md)
**Returns:** [_GQlessError_](gqlesserror.md)

Overrides: Error.constructor

Defined in: [packages/gqless/src/Error/index.ts:5](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Error/index.ts#L5)
Defined in: [packages/gqless/src/Error/index.ts:5](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Error/index.ts#L5)

## Properties

### graphQLErrors

`Optional` **graphQLErrors**: readonly _GraphQLError_[]

Defined in: [packages/gqless/src/Error/index.ts:4](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Error/index.ts#L4)
Defined in: [packages/gqless/src/Error/index.ts:4](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Error/index.ts#L4)

---

Expand Down Expand Up @@ -70,7 +70,7 @@ Defined in: node_modules/.pnpm/typescript@4.2.3/node_modules/typescript/lib/lib.

`Optional` **otherError**: _unknown_

Defined in: [packages/gqless/src/Error/index.ts:5](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Error/index.ts#L5)
Defined in: [packages/gqless/src/Error/index.ts:5](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Error/index.ts#L5)

---

Expand Down Expand Up @@ -135,7 +135,7 @@ Defined in: node_modules/.pnpm/@types+node@14.14.37/node_modules/@types/node/glo
| `message` | _string_ |
| `otherError` | _unknown_ |

Defined in: [packages/gqless/src/Error/index.ts:29](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Error/index.ts#L29)
Defined in: [packages/gqless/src/Error/index.ts:29](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Error/index.ts#L29)

---

Expand All @@ -162,7 +162,7 @@ Defined in: node_modules/.pnpm/@types+node@14.14.37/node_modules/@types/node/glo

### create

`Static`**create**(`error`: _unknown_, `caller?`: Function): [_gqlessError_](gqlesserror.md)
`Static`**create**(`error`: _unknown_, `caller?`: Function): [_GQlessError_](gqlesserror.md)

#### Parameters:

Expand All @@ -171,22 +171,22 @@ Defined in: node_modules/.pnpm/@types+node@14.14.37/node_modules/@types/node/glo
| `error` | _unknown_ |
| `caller?` | Function |

**Returns:** [_gqlessError_](gqlesserror.md)
**Returns:** [_GQlessError_](gqlesserror.md)

Defined in: [packages/gqless/src/Error/index.ts:37](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Error/index.ts#L37)
Defined in: [packages/gqless/src/Error/index.ts:37](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Error/index.ts#L37)

---

### fromGraphQLErrors

`Static`**fromGraphQLErrors**(`errors`: readonly _GraphQLError_[]): [_gqlessError_](gqlesserror.md)
`Static`**fromGraphQLErrors**(`errors`: readonly _GraphQLError_[]): [_GQlessError_](gqlesserror.md)

#### Parameters:

| Name | Type |
| :------- | :------------------------ |
| `errors` | readonly _GraphQLError_[] |

**Returns:** [_gqlessError_](gqlesserror.md)
**Returns:** [_GQlessError_](gqlesserror.md)

Defined in: [packages/gqless/src/Error/index.ts:55](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Error/index.ts#L55)
Defined in: [packages/gqless/src/Error/index.ts:55](https://github.com/gqless/gqless/blob/41c894a/packages/gqless/src/Error/index.ts#L55)
Loading

1 comment on commit af6a437

@vercel
Copy link

@vercel vercel bot commented on af6a437 Apr 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please # to comment.