How to Generate an Entire URL from the URL Schema for Gatsby with GraphQL

4 replies
Last updated: Jan 6, 2021
I did some searching of Slack and didn't find what I was looking for. Is it possible to generate an entire URL from the url schema? Say I want a user to put in their Twitter handle, is it possible to pass down the entire from Sanity or does it make more sense to do the concatenation in Gatsby and just pass the handle? Cheers.
Jan 6, 2021, 6:52 PM
user F
- you can do that in the GROQ query, concatenating strings works pretty much like in JS:
*[_type=="doc"] {
  "twitterUrl": "<>" + handleField
Jan 6, 2021, 8:07 PM
Thanks for the reply
user C
. I really appreciate your time. Groq is new to me. I am using node to query Sanity via graphql. I am trying to see how GROQ fits into that flow.
Jan 6, 2021, 8:44 PM
Speaking from experience, I would bet that once you really get in to GROQ, youll ditch graphql completely (at least on Sanity projects) 🙂 It’s really powerful and I feel like it provides a more “natural” way of writing queries, making it easy to learn.
Jan 6, 2021, 8:57 PM
Thanks for the advice. I will look more into it.
Jan 6, 2021, 9:08 PM – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.