Bad TS types prevent setting of defaultOptions
See original GitHub issueI get a type error with this code:
const client = new AWSAppSyncClient(
{
url: appSyncConfig.graphqlEndpoint,
region: appSyncConfig.region,
auth: {
type: appSyncConfig.authenticationType,
// credentials: () => Auth.currentCredentials(),
apiKey: () => appSyncConfig.apiKey,
},
},
{
defaultOptions: {
watchQuery: {
fetchPolicy: 'cache-and-network',
},
},
}
);
ERROR in /Volumes/SuperData/Sites/reelcrafter/rc-ts/src/bootstrap/apollo-setup.ts
17:3 Argument of type '{ defaultOptions: { watchQuery: { fetchPolicy: "cache-and-network"; }; }; }' is not assignable to parameter of type 'ApolloClientOptions<InMemoryCache>'.
Property 'link' is missing in type '{ defaultOptions: { watchQuery: { fetchPolicy: "cache-and-network"; }; }; }'.
15 | },
16 | },
> 17 | {
| ^
18 | defaultOptions: {
19 | watchQuery: {
20 | fetchPolicy: 'cache-and-network',
ApolloClientOptions
requires link
and cache
to be passed. We need a way to be able to set the global fetchPolicy
.
This code functions properly, and sets the right fetch policy. It’s just that the type used is probably not the best option. I’m looking into somehow creating a new interface based off of ApolloClientOptions
that doesn’t have link
and cache
in it.
@manueliglesias I’m open to other ideas as well.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
[ban-types] Default options are never removed · Issue #686
I'm OK with the default rule, e.g., for Object, but I don't like that there's no way to disable (or change) the fixWith...
Read more >ban-ts-comment - TypeScript ESLint
TypeScript provides several directive comments that can be used to alter how it processes files. Using these to suppress TypeScript compiler errors reduces ......
Read more >Setting default value for TypeScript object passed as ...
The trick is to first put in brackets what keys you want to pick from the argument object, with key=value for any defaults....
Read more >Configuring Vitest
To configure vitest itself, add test property in your Vite config ... You can retrieve Vitest's default options to expand them if needed:...
Read more >Documentation - Do's and Don'ts
WRONG */. function reverse(s: String): String;. ✓ Do use the types number , string ... Don't ever have a generic type which doesn't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@manueliglesias Works great!
Cool! It would be great if you can try the code from #226