mid
mid
TTCTheo's Typesafe Cult
Created by mid on 4/11/2023 in #questions
useSession must be wrapped in a <SessionProvider />
16 replies
TTCTheo's Typesafe Cult
Created by mid on 4/3/2023 in #questions
Forward Ref with SVG
const ComponentToRender = dynamic(() => import('./../lib/assets/svg/1.svg'), {
loading: () => <p>Loading...</p>,
})
// eslint-disable-next-line react/display-name
const ForwardedRefComponent = React.forwardRef((props, ref) => (
# I get an error here
<ComponentToRender {...props} forwaredRef={ref}/>
))
const ComponentToRender = dynamic(() => import('./../lib/assets/svg/1.svg'), {
loading: () => <p>Loading...</p>,
})
// eslint-disable-next-line react/display-name
const ForwardedRefComponent = React.forwardRef((props, ref) => (
# I get an error here
<ComponentToRender {...props} forwaredRef={ref}/>
))
2 replies
TTCTheo's Typesafe Cult
Created by mid on 2/16/2023 in #questions
Static type checking between resolvers and typedef
// A schema is a collection of type definitions (hence "typeDefs")
// that together define the "shape" of queries that are executed against
// your data.
import gql from 'graphql-tag'
export const typeDefs = gql`
# Comments in GraphQL strings (such as this one) start with the hash (#) symbol.

# This "Book" type defines the queryable fields for every book in our data source.
type Book {
title: String
author: String
}

# The "Query" type is special: it lists all of the available queries that
# clients can execute, along with the return type for each. In this
# case, the "books" query returns an array of zero or more Books (defined above).
type Query {
books: [Book]
}
`;
// A schema is a collection of type definitions (hence "typeDefs")
// that together define the "shape" of queries that are executed against
// your data.
import gql from 'graphql-tag'
export const typeDefs = gql`
# Comments in GraphQL strings (such as this one) start with the hash (#) symbol.

# This "Book" type defines the queryable fields for every book in our data source.
type Book {
title: String
author: String
}

# The "Query" type is special: it lists all of the available queries that
# clients can execute, along with the return type for each. In this
# case, the "books" query returns an array of zero or more Books (defined above).
type Query {
books: [Book]
}
`;
Resolver
import { books } from "./types/books";
import { prisma } from "../db/client";

export const resolvers = {
Query: {
books: async () => {
return await prisma.book.findMany();
},
},
};
import { books } from "./types/books";
import { prisma } from "../db/client";

export const resolvers = {
Query: {
books: async () => {
return await prisma.book.findMany();
},
},
};
3 replies
TTCTheo's Typesafe Cult
Created by mid on 2/16/2023 in #questions
How to setup grapql(t3 stack) with typeschecking?
I want to use the @apollo/server and @apollo/client
10 replies
TTCTheo's Typesafe Cult
Created by mid on 2/13/2023 in #questions
Zod with custom type
Need custom type validation in zod. help!!
type media_type = "all" | "movie" | "tv" | "person"
type media_type = "all" | "movie" | "tv" | "person"
And use something like
getTrending: publicProcedure
.input(
z.object({
media_type: z.custom() //need the media_type check here)
})
)
.query(({ input }) => {
return {
...input
};
}),
getTrending: publicProcedure
.input(
z.object({
media_type: z.custom() //need the media_type check here)
})
)
.query(({ input }) => {
return {
...input
};
}),
12 replies
TTCTheo's Typesafe Cult
Created by mid on 2/10/2023 in #questions
Extending union types by interface
export declare type RouteProps = PathRouterProps | LayoutRouterProps |IndexRouteProps;
interface IOwnProps extends RouteProps {
hasAnyAuthorities?: string[];
}
export declare type RouteProps = PathRouterProps | LayoutRouterProps |IndexRouteProps;
interface IOwnProps extends RouteProps {
hasAnyAuthorities?: string[];
}
I am getting An interface can only extend an object type or intersection of object types with statically known members
3 replies
TTCTheo's Typesafe Cult
Created by mid on 2/6/2023 in #questions
Hello
4 replies