-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
I often have to do a bunch of regexes to get the text I actually need. If I could put it in my query, that'd be even better.
Here is an example:
I have a lil query that grabs some data from the google play-store. I do my pre-processing of input via js template strings in the query, and I'd like to do my post-processing in the query itself:
const details = (id, country='US', lang='en') => graphql(schema, `{
page(url: "https://play.google.com/store/apps/details?id=${id}&hl=${lang}_${country}"){
title: text(selector: "[itemprop='name']")
icon: attr(selector: "[itemprop='image']", name: "src")
developerName: text(selector: "a[href^='/store/apps/dev']")
developerUrl: attr(selector: "a[href^='/store/apps/dev']", name: "href")
developerId: attr(selector: "a[href^='/store/apps/dev']", name: "href", search="/store/apps/dev?id=(.+)")
}
}`)
In this example, I am pulling developerId
from the same place I get developerUrl
, extracting the id from the regex search
. I'm not quite sure how to handle multiple matches, but it would be pretty useful, even if it just returned the 1st match:
{
"data": {
"page": {
"title": "Hello Neighbor",
"icon": "https://lh3.googleusercontent.com/r1wx-kmI9I_zxv8UIF_0_YvmhoLOx25mjT23GCO4bse6H-pgqfjZ5Tvz3HRJ0i2HdEoQ=s100",
"developerName": "tinyBuild",
"developerUrl": "/store/apps/dev?id=4988311280735374056",
"developerId": "4988311280735374056"
}
}
}
Is there interest in this? Should I make a PR?
Metadata
Metadata
Assignees
Labels
No labels