Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Field alias support #110

Merged
merged 3 commits into from
Apr 30, 2022
Merged

Conversation

lorefnon
Copy link
Contributor

@lorefnon lorefnon commented Apr 18, 2022

This extends the API to support field aliasing, which is quite necessary when same field has to be fetched multiple times with different args/selections.

Usage:

const selection = query(t => [
    t.images({ count: 10 }, t => [
        t.title(),
        t.url()
    ]).as("recentPhotos"),
    t.images({ count: 10, author: "lorefnon" }, t => [
        t.title(),
        t.url()
    ]).as("ownPhotos")
]).toQuery({ queryName: "fetchPhotos" })
query fetchPhotos {
    recentPhotos: images(count: 10) {
        title
        url
    }
    ownPhotos: images(count: 10, author: "lorefnon") {
        title
        url
    }
}

@vercel
Copy link

vercel bot commented Apr 18, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/timkendall/tql/BZmsnyBzEEKGkBBpJpdQFRvaestc
✅ Preview: https://tql-git-fork-lorefnon-field-alias-support-timkendall.vercel.app

Copy link
Owner

@timkendall timkendall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, been meaning to get around to this! Please add new type-level test suite for this functionality in field-alias.test-d.ts (or similar) and we can get this merged. Appreciate the work.

@vercel
Copy link

vercel bot commented Apr 29, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
tql ✅ Ready (Inspect) Visit Preview Apr 29, 2022 at 6:00AM (UTC)

@lorefnon
Copy link
Contributor Author

@timkendall Thanks. I have added the type test.

@timkendall timkendall merged commit 3e16a17 into timkendall:master Apr 30, 2022
@timkendall
Copy link
Owner

Published as @timkendall/tql@1.0.0-rc.8, @timkendall/tql@beta, @timkendall/tql-gen@1.0.0-rc.8, @timkendall/tql-gen@latest

@timkendall timkendall mentioned this pull request Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants