Skip to content
/ content Public

Code generated TypeScript and Swift types for Quartz GraphQL queries

Notifications You must be signed in to change notification settings

Quartz/content

Folders and files

NameName
Last commit message
Last commit date
Feb 2, 2022
Apr 21, 2022
Apr 21, 2022
Apr 21, 2022
Apr 21, 2022
Oct 12, 2020
Oct 24, 2020
Oct 12, 2020
Mar 10, 2021
Mar 10, 2021
Feb 18, 2021
Oct 24, 2020
Nov 11, 2020
Mar 10, 2021
Mar 10, 2021
Oct 16, 2020
Oct 24, 2020
Oct 24, 2020

Repository files navigation

Quartz Content Queries

This repo contains shared GraphQL queries for Quartz content at content.qz.com/graphql.

Queries are used to automatically generate TypeScript types and React hooks for React projects, and Swift types for iOS projects, using Apollo. This repo hosts both an NPM package and a Swift package for client use.

Adding queries

Shared queries can be found in /Queries. Fragments that might be shared in multiple queries are grouped in /Queries/Fragments. Queries related to a single page or function are grouped into folders, for instance, /Queries/Home.

What about __typename?

There’s no need to include __typename in your queries! Types will be introspected automatically.

Generating type definitions

Type definitions are generated automatically when merging to the main branch. (See .github/workflows/generation.yml). However, it’s a good idea to run type generation locally before opening a PR; it can help catch errors like missing fragments or name collisions. If you’d like to test your PR in a consuming repo like qz-react, open the PR, wait for the bot to commit the type definitions, then install the resulting commit in your repo, e.g.:

npm i --save Quartz/content#mysha1

Releases

We’re using GitHub Releases (tags) for versioning. Click on “Releases”, then “Draft a new release”, and tag and title your release using semantic versioning. To update the package in a client project, use: npm i --save Quartz/content#0.0.8.

semver

Client usage

In React projects

npm i --save Quartz/content#0.1.0 # we’re using GitHub Releases (tags) for versioning

Hooks are automatically generated for each operation (query or mutation).

import { useLatestGuidesQuery } from '@quartz/content';

export default function MyComponent() {
	const { data, loading, error } = useLatestGuidesQuery( { variables: { perPage: 3 } } );

In iOS projects

// Package.swift
dependencies: [
    .package(url: "https://github.com/Quartz/content", from: "0.0.8"),
],