Transcript from the "Wrapping Up" Lesson
>> Scott Moss: Yes.
>> Speaker 2: When I'm writing resolvers, do I need to worry about concurrency?
>> Scott Moss: It depends on what language you're using. [LAUGH] Yeah, if you're using Node, do you need to worry about concurrency? Yeah, you do. I can't speak for other languages. But yeah, you do need to keep in mind concurrency.
[00:00:24] And it really depends on the client, see, because if we're using Apollo, like I said, Apollo will batch queries for you. So if I'm a client, if I send up ten queries, and one loop, one event loop is gonna batch all of them. And it's going to take every single one of those queries and run them in parallel.
[00:00:38] So your database is gonna get hit in parallel. And if one of those things is depending on a value but something else just had a race condition to finish before it and updated the cache, everything's messed up. So, yeah, you have to deal with that. You can turn up batching if you want, which will help it.
[00:00:56] But if you write it in a way that where concurrency didn't matter, not from a performance standpoint, but from this data correct standpoint, then you won't have to worry about it. But for performance, 100% gonna have to worry about concurrency. Any questions online?
>> Speaker 3: There's one, can we have links to any good open source projects using GraphQL probably?
>> Scott Moss: My God, there's so many of them. Okay, okay, Prisma is a good one, never used it, but I know it's good. Basically, it creates an ORM based off a database for your graph. Actually, it has nothing to do with graph I think they moved away from GraphQL but it basically creates a really sick ORM that you can use.
[00:01:42] So instead of using something like ctx.models.Pet.create, you get a type checked or that's validated against some database schema that you have, no matter what database you have. And they started off using it with GraphQL, but they kinda just like, actually this works for everything. So, they've made a lot of product changes, and this is one of them.
[00:02:01] So I would check them out, really cool. I already talked about Hasura, these folks are really cool, super talented people. That's really good. Another one is graphql-anywhere.
>> Scott Moss: Which is exactly what it sounds like. You can run graphql-anywhere. That's literally what it says here, run a GraphQL query anywhere.
[00:02:25] What does that mean? Well, if you think about it, if all you have was some resolvers, a schema and then a query, you could output anything, you could execute that in any environment and that's basically what graphql-anywhere does. I guess it's pretty low level but if you start understanding GraphQL pretty well, you'll realize that you can run graphql-anywhere.
[00:02:44] Like for instance, here's an example of getting some REST response back from GitHub, and then executing it again, say GraphQL query client side and getting back exactly what you asked for. So they're just picking and plucking from an object, and then we're using GraphQL to query that object.
[00:03:00] So, there's a lot of different scenarios. Like I said, you can build applications with this, you can write CSS with this. Here's an example of generating React components using GraphQL. It gets pretty crazy, look at this. Look at this. I don't know who would wanna do this, but-
>> Group: [LAUGH]
>> Scott Moss: You can do it. You can do it. It's possible, yes.
>> Speaker 5: So, I read about Apollo server that can deploy two cloud flares edge workers.
>> Scott Moss: Yeah.
>> Speaker 5: And I was just wondering what you've heard about that in terms of how well it performs in that situation.
>> Scott Moss: Yeah, so we use their products. We use it in beta. We use cloud for our workers in beta, we were some of the first people to use them, I think it works pretty well actually. The thing with Apollo is that although they're really good company and have a lot of good open source, they're a product, they're trying to make money.
[00:03:55] So a lot of the stuff that's really useful, you have to pay for after you've already used a lot of open source stuff and to me I was like, I don't mind paying for it, but I'm already this close, I might as well make it myself. So we end up just making stuff ourselves, but I think it's really good if you opt into their ecosystem, especially on something like Cloudflare Workers.
[00:04:12] Or another one which is like a fly.io, which is just like Cloudfare Workers but I don't know, it might be better, it depends on what you're doing. I think it works pretty good, that's what's called a gateway, a GraphQL gateway, that's basically what they're calling it. So it sits in front of, I mean, it's your intro to your CDN, that can go anywhere, you can talk to any single entity.
[00:04:36] So, basically you started getting into what's called Apollo Federation,
>> Scott Moss: Which is basically creating a, yeah, you just gotta read this. It's basically creating a, [LAUGH] it's so complicated. You're creating a gateway of many different services, all that also are GraphQL. And they all share the same schema.
[00:05:01] Yes, like a graph of graphs, and they all know about each other. They know everything about each other. That's all type-safe and it's all extendable. And you got different teams working on stuff and nobody hurts anybody, it's that. And that's what you start getting into. Yeah, it's pretty crazy.
[00:05:16] Yeah, so I talked about graphql-yoga. This is something also created by the Prisma team. It's just another alternative to the Apollo server, it's a server for GraphQL, they have their own features, they all follow the same specs, the same spec, you write the resolvers. Everything's exactly the same way you write to type definitions.
[00:05:33] It's just that they have different things, like for instance, they have mocks here. They have middlewares, which is I think is really cool. There's a lot of different features that they have versus what Apollo may or may not have. So, definitely check it out. Let me see.
>> Scott Moss: Can't think of anything else super cool off the top of my head, you know what, that's why they have this for times like this.
[00:06:02] Awesome graphql, just go there. Awesome graphql, there's a list of awesome GraphQL things. So, I would imagine you would find something super legit inside of here.