Getting Started with GraphQL & jQuery
GraphQL:
GraphQL is an opensource Query language invented by Facebook that allows clients to formulate queries to get different results. its mean goal is to combine multiple services and endpoints into a single endpoint.
Basically GraphQL is an alternative of REST.
Features of GraphQL
- Hierarchical — queries look exactly like the data they return.
- Client-specified queries — the client has the liberty to dictate what to fetch from the server,
- Strongly typed — you can validate a query syntactically and within the GraphQL type system before execution. This also helps leverage powerful tools that improve the development experience, such as GraphiQL.
- Introspective — you can query the type system using the GraphQL syntax itself. This is great for parsing incoming data into strongly-typed interfaces, and not having to deal with parsing and manually transforming JSON into an object.
A simple API server with GaphQL: https://github.com/solaimanshadin/getting-started-with-graphQL
2. jQuery:
jQuery is a JavaScript library designed to simplify HTML DOM tree traversal and manipulation, as well as event handling, CSS animation, and AjaxjQuery, once the king of frontend JavaScript libraries, isn’t nearly as popular as it once was.
Basic syntax is: $(selector).action()
- A $ sign to define/access jQuery
- A (selector) to “query (or find)” HTML elements
- A jQuery action() to be performed on the element(s)
jQuery Syntax For Event Methods
In jQuery, most DOM events have an equivalent jQuery method.
To assign a click event to all paragraphs on a page, you can do this:
$(“p”).click();
Example
$("p").click(function(){
$(this).hide();
});