Class: GraphQLClient

GraphQLClient


new GraphQLClient()

The GraphQLClient retrieves data from the FAIRSharing API and sends it to the front-end. Be careful, this is a singleton and trying to cast new instances will return the existing instance. Be also careful, its constructor is async !!

Source:
Returns:
  • to use this object you need to do "await new ClassName()" or use .then(callback)
Type
Promise

Methods


buildQuery(query)

Transform the JSON query into a string for graphQL

Parameters:
Name Type Description
query Object

the query coming from the JSON file

Source:
Returns:

{query: queryString} - a valid graphQL query string to execute

Type
Object

<async> executeQuery(query)

Execute the given query (coming from a json file, see /queries/getRecords.json)

Parameters:
Name Type Description
query Object

the query coming from the JSON file sending to the API.

Source:
Returns:
Type
Promise

<async> getData(queryString)

Takes the query, post it with axios and returns the raw data

Parameters:
Name Type Description
queryString Object

processed request coming out of buildQuery() or a GraphQL query string

Source:
Returns:
  • an axios promise representing the server response.
Type
Promise

setHeader(jwt)

Add the authorization token to the headers

Parameters:
Name Type Description
jwt String

the user json web token

Source: