Skip to content

Commit

Permalink
docs: document the release process for graphql-hooks (#1125)
Browse files Browse the repository at this point in the history
* docs: document the release process for graph1l-hooks

* docs: link to release docs from contributing docs

* chore: renamed to RELEASE_PROCESS.MD

* chore: renamed to RELEASE_PROCESS.MD
  • Loading branch information
williamlines authored Oct 2, 2023
1 parent 7c4958d commit 363e75a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 13 deletions.
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ For more information on `@all-contributors` see it's [usage docs](https://allcon

When merging a pull request to `master`, the squashed commit message should follow the [Conventional Commits](https://www.conventionalcommits.org) specification. This enables us to automatically generate CHANGELOGs & determine a semantic version bump.

- `npm test`
- `NPM_CONFIG_OTP=<your-otp> npm run release`

Follow the prompts from [`lerna publish`](https://lernajs.io/#command-publish)
Follow the [guide found here](./RELEASE_PROCESS.md) to make a release.

---

Expand Down
32 changes: 32 additions & 0 deletions RELEASE_PROCESS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Releasing graphql-hooks

_Note that this guide is intended for people in charge of managing internal releases in NearForm. If you have made changes to this repository, in most cases you should not need to take any action for the repo to be released._

If you need to release graphql-hooks, you should follow these steps:

- Ensure you have sufficient permissions to publish the graphql-hooks package on npm. If you require permissions, contact IT.

- Clone this repository locally

- Run `npm install` in the root directory. When the installation is complete, the script will automatically run the build command, `npm run build:packages`. Ensure the builds complete successfully, if they do not, you may need to use a different version of node and re-run the command.

- Create a GitHub personal access token with the following permissions on the graphql-hooks repo:

- Metadata read-only
- Content read and write
- Issues read and write
- Pull Requests read and write

- Set a the `GH_TOKEN` environment variable in your terminal to the token you just made using

```
export GH_TOKEN=<your-token-here>
```

- Authenticate to npm in the same terminal by running `npm login`.

- Check the tests are passing with `npm test`

- Run `npm run release` to run the release script. Follow the prompts from [`lerna publish`](https://lernajs.io/#command-publish), the script will ask you to verify to npm with 2FA, so have your authentication service ready.

- Once the script has finished running, the release is complete. You can verify this by checking the [npm page](https://www.npmjs.com/package/graphql-hooks), and the [latest releases on the GitHub repo](https://github.com/nearform/graphql-hooks/releases/tag/graphql-hooks%406.3.1).
29 changes: 20 additions & 9 deletions packages/graphql-hooks/src/LocalGraphQLClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ class LocalGraphQLClient extends GraphQLClient {
if (result instanceof LocalGraphQLError) {
return { error: result }
}
const {data, errors} = collectErrorsFromObject(result)
const { data, errors } = collectErrorsFromObject(result)
if (errors.length > 0) {
return {data, error: new LocalGraphQLError({graphQLErrors: errors as TGraphQLError[]})}
return {
data,
error: new LocalGraphQLError({
graphQLErrors: errors as TGraphQLError[]
})
}
} else {
return {data}
return { data }
}
})
}
Expand All @@ -82,7 +87,10 @@ function isObject(o: unknown): o is object {
return o === Object(o)
}

function collectErrorsFromObject(objectIn: object): {data: object | null, errors: Error[]} {
function collectErrorsFromObject(objectIn: object): {
data: object | null
errors: Error[]
} {
const data: object = {}
const errors: Error[] = []

Expand All @@ -94,10 +102,13 @@ function collectErrorsFromObject(objectIn: object): {data: object | null, errors
}
}

return {data, errors}
return { data, errors }
}

function collectErrorsFromArray(arrayIn: object[]): {data: (object | null)[], errors: Error[]} {
function collectErrorsFromArray(arrayIn: object[]): {
data: (object | null)[]
errors: Error[]
} {
const data: (object | null)[] = Array(arrayIn.length)
const errors: Error[] = []

Expand All @@ -109,18 +120,18 @@ function collectErrorsFromArray(arrayIn: object[]): {data: (object | null)[], er
}
}

return {data, errors}
return { data, errors }
}

function collectErrorsFromChild(entry: object) {
if (entry instanceof Error) {
return {data: null, errors: [entry]}
return { data: null, errors: [entry] }
} else if (Array.isArray(entry)) {
return collectErrorsFromArray(entry)
} else if (isObject(entry)) {
return collectErrorsFromObject(entry)
} else {
return {data: entry, errors: null}
return { data: entry, errors: null }
}
}

Expand Down

0 comments on commit 363e75a

Please sign in to comment.