What does GraphQL use internally to query the Sitecore items?
I want to make it clear that Sitecore did not invent or create GraphQL. GraphQL is a pre-existing standard: https://graphql.org/
The Sitecore GraphQL API is an implementation of that standard with some Sitecore-specific bits.
As I understand it, the endpoint is running C# code on the server that is defined for schemas and extenders. It wraps around Sitecore's context database, and ultimately at the very bottom of the layers the content queries are calling the native Sitecore Item API for single Item requests, and the ContentSearch API for searches.
Make sure to take a look at the examples for customization on the JSS site to get an idea of the various things like endpoints, schemas, extenders, etc.: https://jss.sitecore.com/docs/techniques/graphql/graphql-overview