Skip to content

fix(twitter): tolerate missing findGraphQLQueryId in tweets adapter - #84

Open
zzhan111 wants to merge 1 commit into
epiral:mainfrom
zzhan111:fix/twitter-tweets-queryid-fallback
Open

fix(twitter): tolerate missing findGraphQLQueryId in tweets adapter#84
zzhan111 wants to merge 1 commit into
epiral:mainfrom
zzhan111:fix/twitter-tweets-queryid-fallback

Conversation

@zzhan111

Copy link
Copy Markdown

What

Guard the findGraphQLQueryId lookups in twitter/tweets.js so the adapter
tolerates the helper not being present.

Why

The 2026-05-25 refactor (f0cdfbf) extracted findGraphQLQueryId into
twitter/_helper.js for reuse across the Twitter adapters. That works when
adapters are executed with the helper loaded, but when tweets.js runs as a
standalone single-file eval (no _helper.js in scope), the bare call:

const userQueryId = findGraphQLQueryId('UserByScreenName', 'pLsOiyHJ1eFwPJlNmLp4Bg');

throws a ReferenceError before the hardcoded fallback id can ever be used —
so the adapter dies instead of degrading gracefully.

Change

const _findQueryId = typeof findGraphQLQueryId === 'function'
  ? findGraphQLQueryId
  : ((name, fallback) => fallback);
const userQueryId  = _findQueryId('UserByScreenName', 'pLsOiyHJ1eFwPJlNmLp4Bg');
const tweetsQueryId = _findQueryId('UserTweets', 'Y59DTUMfcKmUAATiT2SlTw');

When the shared helper is present it is used exactly as before; when it is
absent the adapter falls back to the hardcoded query ids. No behavioral change
for the helper-loaded path.

🤖 Generated with Claude Code

The 5-25 refactor moved findGraphQLQueryId into twitter/_helper.js for
reuse. When tweets.js runs in a context where _helper.js was not loaded
(e.g. a standalone single-file eval), the bare call throws a
ReferenceError before the hardcoded fallback id can be used.

Guard the lookup: use findGraphQLQueryId when it is a function, else
fall back to the provided hardcoded queryId. Adapter now works both
with and without the shared helper present.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant