leebenson / reactql

Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
https://reactql.org
MIT License
1.82k stars 173 forks source link

Default Apollo Hooks rather than generated HOC for Apollo Queries #177

Open chrischen opened 5 years ago

chrischen commented 5 years ago

"Why Hooks are the future" https://blog.apollographql.com/apollo-client-now-with-react-hooks-676d116eeae2

Hooks have been declared as the future of Apollo client, and also reduces the bundle size (if you only use the apollo hooks API for querying.

Maybe modify codegen.yml to emit hooks like in this example from the internet:

 models.tsx:
    documents: "packages/files-client-state/src/**/*.gql"
    schema: 
      - ./packages/client-state/src/**/*.graphql
      - ./packages-modules/module/server/src/graphql/**/*.graphql
    config:
        namingConvention: keep
        typesPrefix: I
        withMutationFn: true
        withHOC: true
        withComponent: true
        withHooks: true
    preset: "@cdmbase/import-types-preset"
    presetConfig:
      typesPath: "core"
      importTypesNamespace: SchemaTypes
jmandel1027 commented 4 years ago

would love to see hooks support in this as well!

leebenson commented 4 years ago

Totally open to adding hooks. I'm not actively maintaining this project atm, so would appreciate any PRs.