File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
x-pack/plugins/security_solution/public
common/components/exceptions
detections/containers/detection_engine/rules Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -114,9 +114,12 @@ export const AddExceptionModal = memo(function AddExceptionModal({
114114 const { loading : isSignalIndexLoading , signalIndexName } = useSignalIndex ( ) ;
115115 const [
116116 { isLoading : isSignalIndexPatternLoading , indexPatterns : signalIndexPatterns } ,
117- ] = useFetchIndexPatterns ( signalIndexName !== null ? [ signalIndexName ] : [ ] ) ;
117+ ] = useFetchIndexPatterns ( signalIndexName !== null ? [ signalIndexName ] : [ ] , 'signals' ) ;
118118
119- const [ { isLoading : isIndexPatternLoading , indexPatterns } ] = useFetchIndexPatterns ( ruleIndices ) ;
119+ const [ { isLoading : isIndexPatternLoading , indexPatterns } ] = useFetchIndexPatterns (
120+ ruleIndices ,
121+ 'rules'
122+ ) ;
120123
121124 const onError = useCallback (
122125 ( error : Error ) => {
Original file line number Diff line number Diff line change @@ -97,9 +97,12 @@ export const EditExceptionModal = memo(function EditExceptionModal({
9797 const { loading : isSignalIndexLoading , signalIndexName } = useSignalIndex ( ) ;
9898 const [
9999 { isLoading : isSignalIndexPatternLoading , indexPatterns : signalIndexPatterns } ,
100- ] = useFetchIndexPatterns ( signalIndexName !== null ? [ signalIndexName ] : [ ] ) ;
100+ ] = useFetchIndexPatterns ( signalIndexName !== null ? [ signalIndexName ] : [ ] , 'signals' ) ;
101101
102- const [ { isLoading : isIndexPatternLoading , indexPatterns } ] = useFetchIndexPatterns ( ruleIndices ) ;
102+ const [ { isLoading : isIndexPatternLoading , indexPatterns } ] = useFetchIndexPatterns (
103+ ruleIndices ,
104+ 'rules'
105+ ) ;
103106
104107 const onError = useCallback (
105108 ( error ) => {
Original file line number Diff line number Diff line change @@ -38,7 +38,14 @@ const DEFAULT_BROWSER_FIELDS = {};
3838const DEFAULT_INDEX_PATTERNS = { fields : [ ] , title : '' } ;
3939const DEFAULT_DOC_VALUE_FIELDS : DocValueFields [ ] = [ ] ;
4040
41- export const useFetchIndexPatterns = ( defaultIndices : string [ ] = [ ] ) : Return => {
41+ // Fun fact: When using this hook multiple times within a component (e.g. add_exception_modal & edit_exception_modal),
42+ // the apolloClient will perform queryDeduplication and prevent the first query from executing. A deep compare is not
43+ // performed on `indices`, so another field must be passed to circumvent this.
44+ // For details, see https://github.com/apollographql/react-apollo/issues/2202
45+ export const useFetchIndexPatterns = (
46+ defaultIndices : string [ ] = [ ] ,
47+ queryDeduplication ?: string
48+ ) : Return => {
4249 const apolloClient = useApolloClient ( ) ;
4350 const [ indices , setIndices ] = useState < string [ ] > ( defaultIndices ) ;
4451
@@ -74,6 +81,7 @@ export const useFetchIndexPatterns = (defaultIndices: string[] = []): Return =>
7481 variables : {
7582 sourceId : 'default' ,
7683 defaultIndex : indices ,
84+ ...( queryDeduplication != null ? { queryDeduplication } : { } ) ,
7785 } ,
7886 context : {
7987 fetchOptions : {
You can’t perform that action at this time.
0 commit comments