kevinlu1248 / hasura

The Unlicense
0 stars 0 forks source link

Sweep: add ApolloClient type to client.tsx #1

Open kevinlu1248 opened 1 year ago

kevinlu1248 commented 1 year ago

hasura/client.tsx

 ): ApolloClient<any> { 
uses ApolloClient from @apollo/client, we should use our own ApolloClient type that should be created and should look like this:
import { ApolloClient as  BaseApolloClient} from '@apollo/client';
export type ApolloClient = BaseApolloClient<any> & {
  path: string;
  ssl: boolean;
  jwt_token: string;
}

Instead of using new ApolloClient use new BaseApolloClient (because new ApolloClient is just a type/interface, not a class

Checklist - [X] `client.tsx` ✅ Commit [`9cfb1dd`](https://github.com/kevinlu1248/hasura/commit/9cfb1dd92d2b7ab13df3623da76c2c519c942e9a)
• Import `ApolloClient` as `BaseApolloClient` from the `@apollo/client` library. • Define a new `ApolloClient` type that extends `BaseApolloClient` and includes the additional properties `path`, `ssl`, and `jwt_token`. • Replace all instances of `new ApolloClient` with `new BaseApolloClient`.
Sandbox Execution Logs
trunk init 1/3 ✓
⡿ Downloading Trunk 1.15.0...
⡿ Downloading Trunk 1.15.0...
⢿ Downloading Trunk 1.15.0...
⣻ Downloading Trunk 1.15.0...
⣽ Downloading Trunk 1.15.0...
⣾ Downloading Trunk 1.15.0...
⣷ Downloading Trunk 1.15.0...
✔ Downloading Trunk 1.15.0... done
⡿ Verifying Trunk sha256...
✔ Verifying Trunk sha256... done
⡿ Unpacking Trunk...
✔ Unpacking Trunk... done

✔ 9 linters were enabled (.trunk/trunk.yaml)
  actionlint 1.6.25 (4 github-workflow files)
  checkov 2.4.9 (3 json, 6 yaml files)
  git-diff-check (21 files)
  markdownlint 0.36.0 (1 markdown file) (created .markdownlint.yaml)
  osv-scanner 1.4.0 (1 lockfile file)
  prettier 3.0.3 (1 javascript, 2 json, 1 markdown, 6 typescript, 6 yaml files)
  trivy 0.45.0 (1 lockfile, 6 yaml files)
  trufflehog 3.56.0 (22 files)
  yamllint 1.32.0 (6 yaml files) (created .yamllint.yaml)
Next Steps
 1. Read documentation
    Our documentation can be found at https://docs.trunk.io
 2. Get help and give feedback
    Join the Trunk community at https://slack.trunk.io
trunk fmt client.tsx 2/3 ✓

 ✔ Formatted client.tsx
Re-checking autofixed files...

Checked 1 file
✔ No issues
trunk check --fix client.tsx 3/3 ✓

Checked 1 file
✔ No issues
sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/kevinlu1248/hasura/pull/2.

💎 Sweep Pro: I used GPT-4 to create this ticket. You have unlimited GPT-4 tickets. To retrigger Sweep, edit the issue.


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/kevinlu1248/hasura/blob/202846e0e4a258a70af02fa96f66ae4fee9e5dd2/client.tsx#L1-L133 https://github.com/kevinlu1248/hasura/blob/202846e0e4a258a70af02fa96f66ae4fee9e5dd2/package.json#L1-L47 https://github.com/kevinlu1248/hasura/blob/202846e0e4a258a70af02fa96f66ae4fee9e5dd2/README.md#L1-L84
I also found the following external resources that might be helpful: **Summaries of links found in the content:** https://github.com/deep-foundation/hasura/blob/947d587f3e53ccecf47b25fbfe5dc61fa43df321/client.tsx#L54: The page is a TypeScript file named `client.tsx` from the GitHub repository `deep-foundation/hasura`. The relevant code snippet is on line 54, where the `ApolloClient` type is being used. The suggestion is to use a custom `ApolloClient` type that extends the `BaseApolloClient` type from the `@apollo/client` library. The custom `ApolloClient` type should have additional properties such as `path`, `ssl`, and `jwt_token`. The suggestion is to import `ApolloClient` as `BaseApolloClient` and create a new type `ApolloClient` that extends `BaseApolloClient` with the additional properties.

Step 2: ⌨️ Coding

trunk init 1/3 ✓
⡿ Downloading Trunk 1.15.0...
⡿ Downloading Trunk 1.15.0...
⢿ Downloading Trunk 1.15.0...
⣻ Downloading Trunk 1.15.0...
⣽ Downloading Trunk 1.15.0...
⣾ Downloading Trunk 1.15.0...
⣷ Downloading Trunk 1.15.0...
✔ Downloading Trunk 1.15.0... done
⡿ Verifying Trunk sha256...
✔ Verifying Trunk sha256... done
⡿ Unpacking Trunk...
✔ Unpacking Trunk... done

✔ 9 linters were enabled (.trunk/trunk.yaml)
  actionlint 1.6.25 (4 github-workflow files)
  checkov 2.4.9 (3 json, 6 yaml files)
  git-diff-check (21 files)
  markdownlint 0.36.0 (1 markdown file) (created .markdownlint.yaml)
  osv-scanner 1.4.0 (1 lockfile file)
  prettier 3.0.3 (1 javascript, 2 json, 1 markdown, 6 typescript, 6 yaml files)
  trivy 0.45.0 (1 lockfile, 6 yaml files)
  trufflehog 3.56.0 (22 files)
  yamllint 1.32.0 (6 yaml files) (created .yamllint.yaml)
Next Steps
 1. Read documentation
    Our documentation can be found at https://docs.trunk.io
 2. Get help and give feedback
    Join the Trunk community at https://slack.trunk.io
trunk fmt client.tsx 2/3 ✓

 ✔ Formatted client.tsx
Re-checking autofixed files...

Checked 1 file
✔ No issues
trunk check --fix client.tsx 3/3 ✓

Checked 1 file
✔ No issues


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/custom-apollo-client-type.

.


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord