Page 1

  • A guide to GROQ

    Saturday, August 5, 2023
    πŸ•‘14 minute read
    GROQ (Graph Relational Object Queries) is a query language that was created by Sanity to query CMS data. It’s a flexible query language and the use of projections makes it a powerful tool to construct complex and efficient data queries. GROQ vs. GraphQL ...

  • GROQ vs GraphQL

    Friday, August 4, 2023
    πŸ•‘2 minute read
    While GROQ is nominally similar to GraphQL, there are subtle differences. Here's a quick run down of the similarities and differences, so that you can understand the reasons for GROQs existence, and some of it’s use-cases, before using it yourself Both us...

  • Simplify GROQ query with optional fields

    Sunday, May 21, 2023
    πŸ•‘1 minute read
    In working with Sanity and GROQ, there might be instances where you need to filter data using an optional field, and want a default value to kick in when null values are returned. For instance, consider an __i18n field added after a significant amount of c...

  • Filtering data within a GROQ query

    Saturday, May 20, 2023
    πŸ•‘1 minute read
    When dealing with multiple sets of similar data, it's not uncommon to encounter overlapping filters. Let's say you need to pull up all your articles, then categorize them into two subsets: English and French. You might think you need three separate queries...

  • GROQ webhooks in Sanity

    Saturday, May 6, 2023
    πŸ•‘1 minute read
    The webhooks within Sanity CMS offer an amazingly powerful way to send data to 3rd parties when changes to content occur. However, the webhooks often require extra data retrieval to ensure the consuming service has all the necessary information for appropr...

  • Tuple to Object - TypeScript Challenge Explained

    Monday, March 13, 2023
    πŸ•‘1 minute read
    My solution to the Tuple to Object TypeScript Challenge as part of my journey to Understanding the TypeScript Challenges. Given an array, transform it into an object type and the key/value must be in the provided array. Solution Loop over the values in ...

  • Readonly - TypeScript Challenge Explained

    Sunday, March 12, 2023
    My solution to the Readonly TypeScript Challenge as part of my journey to Understanding the TypeScript Challenges. Given a type T, the utility should set the readonly keyword for all properties. Solution Explanation { } return an object/record type re...

  • Pick - TypeScript Challenge Explained

    Saturday, March 11, 2023
    πŸ•‘1 minute read
    My solution to the Pick TypeScript Challenge as part of my journey to Understanding the TypeScript Challenges. The MyPick generic type is a custom version of the native Pick generic function. Given a type T and a union of keys K, the generic function shou...

  • Uses for the TypeScript β€˜as’ assertion

    Thursday, March 9, 2023
    πŸ•‘1 minute read
    In TypeScript there is a as assertion. There are two reasons for this annotation. Firstly it's a way to tell TypeScript that a value is of a certain type which differs from what is being inferred, or has already been set. Essentially, it's used to tell Ty...

  • Understanding the TypeScript Challenges

    Wednesday, March 1, 2023
    πŸ•‘1 minute read
    TypeScript has a robust set of built-in utility types. There are a number of ways to gain better understanding of TypeScript and recreating these utilities is one if the best ways. To guide this learning track it's a good idea to try and complete TypeScrip...