Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Chapter 3) The raw client API #26

Open
KATT opened this issue Feb 1, 2022 · 5 comments
Open

Chapter 3) The raw client API #26

KATT opened this issue Feb 1, 2022 · 5 comments
Assignees
Labels
❕ RFC Request for comments - please comment!

Comments

@KATT
Copy link
Member

KATT commented Feb 1, 2022

The raw client API

The API you'd use if you are writing like a CLI or something with tRPC.

Client API Proposal with Proxy:

import type { appRouter } from './server';
import { createClient } from '@trpc/client';

const client = createClient<typeof appRouter>();

async function main() {
  // you can CMD+click `postById` here and jump straight into your backend
  const byId1 = await client.queries.postById({ input: { id: '1' }});

  // with meta data:
  const byId2 = await client.queries.postById({ 
    input: { id: '2' },
    context: {
      batch: false,
    }
  });


  // For backwards compatability:
  const list = await client.query('postList');
}

The reasoning with input: {} as an options object is that sometimes we might want to pass additional configuration and when input is optional it's a bit iffy to do client.query(undefined, {context: {foo: 'bar'}}

@KATT KATT added the ❕ RFC Request for comments - please comment! label Feb 1, 2022
@KATT KATT pinned this issue Feb 1, 2022
@mmkal

This comment was marked as outdated.

@KATT

This comment was marked as off-topic.

@KATT

This comment was marked as outdated.

@mmkal

This comment was marked as outdated.

@KATT KATT assigned KATT and unassigned mmkal and sachinraja Apr 11, 2022
@KATT KATT moved this to In Progress in Roadmap and priorities Apr 11, 2022
@KATT KATT moved this from In Progress to In Review in Roadmap and priorities Apr 11, 2022
@KATT
Copy link
Member Author

KATT commented Apr 11, 2022

Alright alright -- this is now ready for review again if you want @mmkal. Almost ready to run on all of this now.

@KATT KATT moved this from 👀 In Review to ✅ Done in Roadmap and priorities Jun 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
❕ RFC Request for comments - please comment!
Projects
Archived in project
Development

No branches or pull requests

3 participants