MCPcopy
hub / github.com/graphql/graphiql / push

Method push

packages/graphiql-toolkit/src/storage/query.ts:91–112  ·  view source on GitHub ↗
(item: QueryStoreItem)

Source from the content-addressed store, hash-verified

89 }
90
91 push(item: QueryStoreItem) {
92 const items = [...this.items, item];
93
94 if (this.maxSize && items.length > this.maxSize) {
95 items.shift();
96 }
97
98 for (let attempts = 0; attempts < 5; attempts++) {
99 const response = this.storage.set(
100 this.key,
101 JSON.stringify({ [this.key]: items }),
102 );
103 if (!response?.error) {
104 this.items = items;
105 } else if (response.isQuotaError && this.maxSize) {
106 // Only try to delete last items on LRU stores
107 items.shift();
108 } else {
109 return; // We don't know what happened in this case, so just bailing out
110 }
111 }
112 }
113
114 save() {
115 this.storage.set(this.key, JSON.stringify({ [this.key]: this.items }));

Callers 15

tokenizeFileFunction · 0.80
getGrammarFunction · 0.80
parseObjFunction · 0.80
parseArrFunction · 0.80
forEachStateFunction · 0.80
validateVariablesFunction · 0.80
validateValueFunction · 0.80
mode.test.tsFile · 0.80
mode.test.tsFile · 0.80
mode.test.tsFile · 0.80
activateFunction · 0.80

Calls 1

setMethod · 0.45

Tested by 1

SetInitialStackFunction · 0.64