Skip to content

Commit

Permalink
Apply suggestions from doc review
Browse files Browse the repository at this point in the history
Co-authored-by: Mariana Caetano Pereira <67270558+Mariana-Caetano@users.noreply.github.com>
Co-authored-by: Fanny Chien <fanny.chien@vtex.com.br>
  • Loading branch information
3 people authored and icazevedo committed Jan 30, 2024
1 parent ca7a1b9 commit f447888
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Migrating your store to v2.2.65
# Improvements to API extensions

In this guide, learn how to migrate your store version to v2.2.65 to leverage the latest improvements in the API extension.
In this guide, learn how to migrate your store version to v3.0.0 to leverage the latest improvements in the API extension.

Version 2.2.65 and above, introduces the following enhancements to API extension users:
Version 3.0.0 and above, introduces the following enhancements to API extension users:

- Deprecation of the `@faststore/graphql-utils` package in favor of the [`client-preset`](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client) plugin.

Expand All @@ -15,28 +15,28 @@ Version 2.2.65 and above, introduces the following enhancements to API extension
import { Callout } from 'nextra/components'

<Callout type="info" emoji="ℹ️">
For more details about these changes, also refer to the release note [TBD](/tbd)
For more details about these changes, also refer to the [GitHub releases](/tbd) related to this version.
</Callout>

The `@faststore/graphql-utils` has been replaced by open-source solutions maintained by the community that are now re-exported from `@faststore/core`. There are minor breaking changes on how developers should write GraphQL definitions and invoke queries and mutations, which were introduced in version 2.2.60.
The `@faststore/graphql-utils` has been replaced by open-source solutions maintained by the community that are now re-exported from `@faststore/core`. There are minor breaking changes on how developers should write GraphQL definitions and invoke queries and mutations, which were introduced in version 3.0.0.
## Before you begin
Make sure your store version is updated to v2.2.65 or above. If it’s not updated follow the instructions below:
Make sure your store version is updated to v3.0.0 or above. If it’s not updated follow the instructions below:

1. Open your store code and navigate to the `package.json` file.

2. In `dependencies` > `@faststore/core`, change the version to the following:

```json
"@faststore/core": "^2.2.65",
"@faststore/core": "^3.0.0",
```

3. Open the terminal and run `yarn` to update the version.

## Updating the `gql` helper usage

The `gql` helper serves as a function to define GraphQL operations such as queries, mutations, or fragments within the store code. Before, the function was imported directly from the `@faststore/graphql-utils` which was not recommended. See the example below:

```tsx
// src/fragments/ClientProduct.tsx
```tsx filename="src/fragments/ClientProduct.tsx"
import { gql } from '@faststore/graphql-utils'

export const fragment = gql`
Expand All @@ -55,10 +55,9 @@ export const fragment = gql`
`
```

Now with the v2.2.65, you should import the `gql` helper from `@faststore/core/api`and be called as a function - with the argument between parenthesis. This also applies to query and mutation definitions inside the components. For example:
Now with the v3.0.0, you should import the `gql` helper from `@faststore/core/api`and be called as a function - with the argument between parenthesis. This also applies to query and mutation definitions inside the components. For example:

```tsx {1}
// src/fragments/ClientProduct.tsx
```tsx filename="src/fragments/ClientProduct.tsx" {1}
import { gql } from '@faststore/core/api'

export const fragment = gql(`
Expand Down Expand Up @@ -100,7 +99,7 @@ function CustomComponent() {
}
```

With v2.2.65, queries and mutations are now only invoked using more secure hashes, which are randomly generated and do to that you must pass the query or mutation object - result of the `gql` call - to `useQuery` directly. For example:
With v3.0.0, queries and mutations are now only invoked using more secure hashes, which are randomly generated and do to that you must pass the query or mutation object - result of the `gql` call - to `useQuery` directly. For example:

```tsx
import { gql } from '@faststore/core/api'
Expand Down

0 comments on commit f447888

Please sign in to comment.