Add experimental GraphQL user parser

This commit is contained in:
Zed
2022-01-26 17:24:03 +01:00
parent 535f6936b9
commit ae7091e69d
6 changed files with 49 additions and 34 deletions

View File

@@ -2,14 +2,14 @@
import asyncdispatch, httpclient, uri, strutils, sequtils, sugar
import packedjson
import types, query, formatters, consts, apiutils, parser
import experimental/parser/user
import experimental/parser/[user, graphql]
proc getGraphUser*(id: string): Future[User] {.async.} =
if id.len == 0 or id.any(c => not c.isDigit): return
let
variables = %*{"userId": id, "withSuperFollowsUserFields": true}
js = await fetch(graphUser ? {"variables": $variables}, Api.userRestId)
result = parseGraphUser(js, id)
js = await fetchRaw(graphUser ? {"variables": $variables}, Api.userRestId)
result = parseGraphUser(js)
proc getGraphListBySlug*(name, list: string): Future[List] {.async.} =
let