Generate schema from the GraphQL endpoint on Next.js with Apollo CLI

One of my colleagues recommends using GraphQL Code Generator instead. He provided this example.