GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data.
It provides an efficient, powerful and flexible approach to developing web APIs, and has been compared and contrasted with REST and other web service architectures. It allows clients to define the structure of the data required, and exactly the same structure of the data is returned from the server, therefore preventing excessively large amounts of data from being returned, but this has implications for how effective web caching of query results can be. The flexibility and richness of the query language also add complexity that may not be worthwhile for simple APIs. It consists of a type system, query language and execution semantics, static validation, and type introspection.
GraphQL supports reading, writing (mutating) and subscribing to changes to data (real-time updates).
Whereas, SPARQL acronym for SPARQL Protocol and RDF Query Language is an RDF query language that is, a semantic query language for databases which is able to retrieve and manipulate data stored in Resource Description Framework (RDF) format.
SPARQL is a language to work with Triplestores, graph datasets, and RDF nodes. Graphql is an API language, preferably for working with JSON structures. If you require to apply a graph dataset in your application, perform more advance knowledge discovery like reasoning on the dataset, then you may need a Semantic Web approach to apply SPARQL on top of your dataset.
If you wish to learn about SPARQL query language and RDF query language then visit this Artificial Intelligence Course.