-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cache.identify : Index signature is missing in type #7577
Comments
@jimmycrequer Hmm, it's disappointing that TypeScript is so strict about this, since export interface StoreObject {
__typename?: string;
[storeFieldName: string]: StoreValue;
} As a workaround, you might try adding a On the implementation side, I'm open to relaxing the |
This is a bit difficult when using auto-generated codegen types from neo4j-graphql-js. For the time being, I'll cast the type: type StoreObjectMap = getMap_map & {
[storeFieldName: string]: StoreValue;
};
const map = (data.Map[0].map as unknown) as StoreObjectMap;
const mapRef = client.cache.identify(map); Hopefully we can clean this soon |
The same issue exists if the interface passed is generated by the Apollo CLI (e.g. using an object returned in the data of a mutation). For best compatibility between Apollo created tools, it seems like changing the parameter type might be the best fix. |
Any updates? Would be lovely if I didn't have to cast anymore :) |
I have the same issue
|
It's possible to circumvent the issue by using spread syntax. client.cache.identify({ ...myMap }); Although this could affect performance. Personally I prefer to There is a related issue in the Typescript repo. |
This is unfortunately a difference between TypeScript Apollo Client is now exporting the const myMap: AsStoreObject<MyMapInterface> = ... (Alternatively you could declare I believe that's all we can do on our side, so I'll close this issue :) |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
related to
#6083
Intended outcome:
I want to retrieve the Apollo Client cache ID for a particular object.
Actual outcome:
I get the following TS error.
How to reproduce the issue:
Playground
Versions
TS 4.1
The text was updated successfully, but these errors were encountered: