Giter Club home page Giter Club logo

apollo-hooks-codegen's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

apollo-hooks-codegen's Issues

useQuery: Implement skip option

I've run into a few situations where conditionally executing a query would be very beneficial, for instance when one query returns the ID of the logged in user, and another query would then fetch some more user data based on that ID.

At the moment the (only?) way to do this is to create a component for the query and then conditionally render that. Implementing Apollo's skip option could make this a lot easier ๐Ÿ™‚


Maybe some prior art here trojanowski/react-apollo-hooks#42

Support for interfaces

๐Ÿ‘‹

I'm trying to use [email protected] with GraphQL interfaces, is this supported? At the moment I'm getting an error about unhandled GraphQLOutputType in unwrap with the following schema:

interface Document {
  id: ID!
  permalink: String!
}

type Verdict implements Document @hasScope(scope: ["read:verdict"]) {
  id: ID!
  permalink: String!
}

Logging the type shows it's complaining about Document.

Union Return Type Support

Thanks so much for this library, it's been incredibly helpful for the project I'm building. I was wondering if the following was supported:

schema:

type Mutation {
  unionMethod(body: String): UnionType
}


type FieldError {
  field: String
}

type Errors {
  fieldErrors: [FieldError]
}

type MutationResponse {
  ok: Boolean
}

union UnionType = Errors | MutationResponse

documents:

mutation unionMethod {
  unionMethod(body: "test") {
    ...on Errors {
      fieldErrors {
        field
      }
    }

    ...on MutationResponse {
      ok
    }
  }
}

Currently, this throws an exception TypeError: Cannot create property 'source' on string 'unhandled GraphQLOutputType in unwrap' which appears to be coming from an unhandled case in https://github.com/bearbytes/apollo-hooks-codegen/blob/master/src/transform.ts#L381 .

Are there plans to support this use case, or suggestions for the best way to handle it moving forward? Happy to provide a PR if you have a sense of what we might need.

Thanks!

Generated file fails noUnusedLocals tsc option

When using --noUnusedLocals tsc option, there are two vars that fail for my build: ApolloQueryResult and subscription. (dependent on feature usage I'm sure).

I had to use the add plugin for codegen to make my build pass like this:

  src/graphql.tsx:
    plugins:
      - 'apollo-hooks-codegen'
      - add: '/* Added to bypass noUnusedLocals tsconfig */ type Ditch = ApolloQueryResult<any>; const noop = (...args: Ditch | any) => void args; noop(subscription);'

This works but perhaps this lib could output the vars that are only needed/used to improve this experience.

useQuery: useQuery hook refetching same data given different params

Hey there,

I'm having an issue where the useQuery hook is only fetching data from the first query it executes upon a component mounting. In subsequent component mounts, the query doesn't refetch data with the new variables provided, rather it returns the data from the initial query. I.E. - a user is selected via userId and the useQuery hook fetches that user's userGroups. Groups are then displayed in a userCard. When a different user is chosen, the new user's userId is passed down, but the data that comes back from the useQuery hook is still the first user's userGroups, despite the new userId. Any ideas how I can fix this issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.