import { QueryResponse, } from '@devvit/protos/types/devvit/plugin/redditapi/graphql/graphql_msg.js';
import { RedditAPI } from './RedditAPI.js';
export class GraphQL extends RedditAPI {
    async Query(request, metadata) {
        const response = await this._gqlQueryWithQueryString(request.query, request.variables, metadata);
        return QueryResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async PersistedQuery(request, metadata) {
        let response;
        // SHA256 is 64 characters long. If the ID is shorter, treat it as a legacy persisted ID.
        if (!request.operationName || request.id.length < 64) {
            response = await this._gqlLegacyPersistedQuery(request.id, request.variables, metadata);
        }
        else {
            response = await this._gqlFedPersistedQuery(request.operationName, request.id, request.variables, metadata);
        }
        return QueryResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
}
