From a7b385f0b7017f6ab34b570d0c56549126552bbb Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Mon, 10 Apr 2023 01:46:25 +0100 Subject: [PATCH] Do not cache mutations. --- query.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/query.go b/query.go index 71bb979..62a8e83 100644 --- a/query.go +++ b/query.go @@ -81,6 +81,12 @@ func (c *BaseClient) Query(queryContent string, queryVariables interface{}, quer should_cache = c.cache.enabled } + // if queryContent does not start with `query` then we don't want to cache it + // because it's probably a mutation or subscription. + if !strutil.HasPrefix(queryContent, "query") { + should_cache = false + } + if should_cache { queryHash = strutil.Md5(fmt.Sprintf("%s-%+v", compiledQuery.compiledQuery, queryHeaders)) }