josemarluedke / glimmer-apollo

Ember and Glimmer integration for Apollo Client.
https://glimmer-apollo.com
MIT License
39 stars 15 forks source link

Add UseQuery & UseMutation types #34

Closed josemarluedke closed 3 years ago

josemarluedke commented 3 years ago

This will allow us to create useXYZQuery functions with pre-defining the types and the query:

export function useMyQuery<
  T extends UseQuery<{ cool: boolean }, { isCool: boolean }>
>(ctx: Object, args?: T['args']): T['return'] {
  return useQuery(ctx, () => [
    gql`
      query {
        myQuery {
          id
        }
      }
    `,
    args ? args() : {}
  ]);
}

class MyComponent extends Component {
  myQuery = useMyQuery(this, () => {
    return { variables: { isCool: true } };
  })
}
netlify[bot] commented 3 years ago

❌ Deploy Preview for glimmer-apollo failed.

🔨 Explore the source changes: f3f6aff331fb6e14623df9c95669fc87c8f849a4

🔍 Inspect the deploy log: https://app.netlify.com/sites/glimmer-apollo/deploys/6133ec7664996e0008093dce

netlify[bot] commented 3 years ago

✔️ Deploy Preview for glimmer-apollo ready!

🔨 Explore the source changes: 3e3ea464ec471fb7a142d460a40607cb01a0e72b

🔍 Inspect the deploy log: https://app.netlify.com/sites/glimmer-apollo/deploys/6133eddd0835a90008177ead

😎 Browse the preview: https://deploy-preview-34--glimmer-apollo.netlify.app