fix(graphql): keep query ids fresh
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
|
||||
const root = resolve(import.meta.dirname, '..');
|
||||
const files = [
|
||||
{
|
||||
from: resolve(root, 'src/lib/query-ids.json'),
|
||||
to: resolve(root, 'dist/lib/query-ids.json'),
|
||||
},
|
||||
];
|
||||
|
||||
for (const file of files) {
|
||||
mkdirSync(dirname(file.to), { recursive: true });
|
||||
writeFileSync(file.to, readFileSync(file.from));
|
||||
}
|
||||
|
||||
@@ -28,6 +28,18 @@ const BUNDLE_URL_REGEX =
|
||||
/https:\/\/abs\.twimg\.com\/responsive-web\/client-web(?:-legacy)?\/[A-Za-z0-9.-]+\.js/g;
|
||||
|
||||
const OPERATION_PATTERNS = [
|
||||
// Modern bundles export operations like:
|
||||
// e.exports={queryId:"...",operationName:"CreateTweet",operationType:"mutation",...}
|
||||
{
|
||||
regex: /e\.exports=\{queryId\s*:\s*["']([^"']+)["']\s*,\s*operationName\s*:\s*["']([^"']+)["']/gs,
|
||||
operationGroup: 2,
|
||||
queryIdGroup: 1,
|
||||
},
|
||||
{
|
||||
regex: /e\.exports=\{operationName\s*:\s*["']([^"']+)["']\s*,\s*queryId\s*:\s*["']([^"']+)["']/gs,
|
||||
operationGroup: 1,
|
||||
queryIdGroup: 2,
|
||||
},
|
||||
{
|
||||
regex: /operationName\s*[:=]\s*["']([^"']+)["'](.{0,4000}?)queryId\s*[:=]\s*["']([^"']+)["']/gs,
|
||||
operationGroup: 1,
|
||||
|
||||
Reference in New Issue
Block a user