facebook / facebook/relay

relay-runtime 15.0.0 ConnectionHandler.getConnection() is undefined

Open
#4,611 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Here is my example query:
```
const viewerData = useLazyLoadQuery(graphql`
query RecentSearchesQuery($filterOption: SavedSearchesWith) {
viewer {
...RecentSearches_viewer @arguments(with: $filterOption)
}
}`,
{ filterOption },
queryOptions,
);
```

I'm passing filterOption to RecentSearchesQuery. here is fragment RecentSearches_viewer
```
const savedSearchesData = useFragment(graphql`
fragment RecentSearches_viewer on Viewer
@argumentDefinitions(
first: {type: "Int", defaultValue: 10}
with: {type: "SavedSearchesWith"}
)
{
savedSearches(first: $first, with: $with)
@connection(key: "RecentSearches_viewer__savedSearches") {
edges {
node {
id
query
}
}
}
}`,
viewer
);
```

when I'm going to update the store in the updater of mutation, I'm getting an error:
```
const savedSearchesConnection = ConnectionHandler.getConnection(
viewer,
'RecentSearches_viewer__savedSearches',
);
```

savedSearchesConnection is undefined. but when I didn't pass argument to RecentSearchesQuery, I don't get any error
How can I resolve this issue?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.