Thank you very much for the content you are sharing. I’m fond of your videos; I never got the motivation to learn graphQL because of the whole new terminology to learn but now you got me motivated 😁
One of the best vids on this topic I've seen in the last couple of months ! Very educational. Thanks for willing to share your knowledge, and your time & effort to create this vid. Do you (or smb else) maybe have any idea how to implement one-to-many and many-to-many relations ? And how about Authentication ?
there is a strange behaviour in the code. If you put console.log in for example resolver function or service, the api endpoint is not returning response. So if you put console.log in getAllBooks resolver function and run books query from playground, it won't return any response (it's spinning and response isn't returned). If you remove the console.log, than there won't be any issue.
Hey Jens, thanks for the feedback! Unfortunately, this was just a quick one-off and is not part of a series. I do have some other graphql federation videos on my channel, however.
Hey Leo, I just deleted generated graphql.ts file, and my server runs with no error. Moreover, query & mutation are working correctly. So, what's the use of codegenerator here actually?
this code not works for me "305: Module '"apollo-server"' has no exported member 'makeExecutableSchema'. 1 import { gql, makeExecutableSchema } from 'apollo-server';"
Yeah seems there may have been a change in where it is imported from since when I made the video. www.apollographql.com/docs/apollo-server/migration/ You can do something like import { makeExecutableSchema } from '@graphql-tools/schema';
@@CodeDunks Thank you! I'm curently working on a project and was wondering if I could ask a few questions. Do you have discord maybe? Feel free to add me SlappTasken#8638
Cool, but you don't really use the codegen here, hence why you can't figure out how to type the resolver input. And generating the schema is a bit convoluted. I only played a little bit with graphql and codegen but I came up with this instead: - I split my code into modules src/ and in each i have : --- .gql which is a raw GQL schema (eg: type Foo { id:String! } type Query { fooById(id: String): Foo }) --- a resolvers.ts that implements the needed resolvers for that gql Codegen is setup so it picks up all the gql files, plus some necessary mappings for Prisma, like so: overwrite: true schema: "./src/**/*.gql" documents: null generates: src/generated/graphql.ts: config: useIndexSignature: true contextType: "../context#Context" maybeValue: "T | undefined | null" mappers: Foo: "@prisma/client#Foo as PrismaFoo" scalars: DateTime: Date plugins: - "typescript" - "typescript-resolvers" Note: contextType maps to context.ts where for example: export interface Context { prisma: PrismaClient } Then all you need to do in each of your resolver.ts is to use the generated Resolvers type import { Resolvers } from '../generated/graphql' export const resolvers: Resolvers = { Query: { fooById: (_parent, args, context) => { return context.prisma.foo.findUnique({ where: { id: args.id || undefined }, }) }, }, } Then in my server.ts i recursively load all the gql into a schema and make it executable with the merge of all resolvers. So in that workflow you first write a GQL file, run generate that gets your type, then you can write your resolver automatically typed by the Resolvers type.
Hey Jeremy, this is awesome! I also appreciate the feedback on this. I agree that after getting to play around with this setup some more that I could have made a lot of things in this video a little bit clearer like the things you mentioned in this comment.
The reason for using Postgres over Mongo is due to MongoDB support being in early access for Prisma. www.prisma.io/docs/concepts/database-connectors/mongodb
In almost all his videos, what this guy actually does is copy and paste the code from other forums like medium or something which other people have written. This guy barely knows what's actually happening and we can clearly see that while he explains things. Just spotted another fake RU-vidr. This video too will be copied from somewhere else for sure !