Skip to content

Commit

Permalink
Support apollo-client v3 and it's hooks by default, deprecate hoc and…
Browse files Browse the repository at this point in the history
… components. Updated all imports to latest (#4487)

* support apollo-client v3 andi t's hooks by default, deprecate hoc and components. Updated all imports to latest

* added changeset with migration notes

* fixed for grouping all apollo related imports under the same namespace
  • Loading branch information
dotansimha committed Aug 3, 2020
1 parent 74b5106 commit 091dfea
Show file tree
Hide file tree
Showing 32 changed files with 3,074 additions and 2,843 deletions.
41 changes: 41 additions & 0 deletions .changeset/hip-meals-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
'@graphql-codegen/typescript-react-apollo': major
---

Support Apollo-Client v3 by default (instead of v2), and generate React Hooks be default. HOC and Components are now disabled by default.

Apollo Client v3 has React support integrated as part of the core package now, so that means that some imports, identifiers and usage should be updated. [You can read more about migrating to Apollo-Client v3 here](https://www.apollographql.com/docs/react/migrating/apollo-client-3-migration/)

That means that imports are now generated from `@apollo/client` package, including `gql` tag. React Hooks are generated by default, and HOC and Components are not generated.

## Migration Notes

If you are still using the [deprecated](https://github.com/apollographql/react-apollo) `react-apollo` package, please set this configuration:

```yaml
config:
reactApolloVersion: 2
```

If you are still using the generated React HOC, please set this additional configuration:

```yaml
config:
reactApolloVersion: 2
withHOC: true
```

If you are still using the generated React Components, please set this additional configuration:

```yaml
config:
reactApolloVersion: 2
withComponent: true
```

If you don't need the generated React Hooks (turned on by default now), please also set:

```yaml
config:
withHooks: false
```
14 changes: 9 additions & 5 deletions dev-test/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ generates:
- typescript
- typescript-operations
- typescript-react-apollo
./dev-test/githunt/types.reactApollo.v2.tsx:
schema: ./dev-test/githunt/schema.json
documents: ./dev-test/githunt/**/*.graphql
config:
reactApolloVersion: 2
plugins:
- typescript
- typescript-operations
- typescript-react-apollo
./dev-test/githunt/types.reactApollo.customSuffix.tsx:
schema: ./dev-test/githunt/schema.json
documents: ./dev-test/githunt/**/*.graphql
Expand All @@ -182,8 +191,6 @@ generates:
- typescript
- typescript-operations
- typescript-react-apollo
config:
withHooks: true
./dev-test/githunt/types.apolloAngular.ts:
schema: ./dev-test/githunt/schema.json
documents: ./dev-test/githunt/**/*.graphql
Expand Down Expand Up @@ -347,7 +354,4 @@ generates:
reactApolloVersion: 3
gqlImport: graphql-tag
hooksImportFrom: '@apollo/react-hooks'
withHooks: true
withHOC: false
withComponent: false
withMutationFn: false

0 comments on commit 091dfea

Please sign in to comment.