🚧GraphQL (WIP)

GraphQL is a query language for APIs that provides a more efficient, powerful, and flexible alternative to REST. It allows clients to request only the data they need, and nothing more, streamlining interactions between the client and server.

Differences between REST and GraphQL

  • Data Fetching:

    • REST: Multiple endpoints are needed to fetch different types of data.

    • GraphQL: A single endpoint can be used to fetch all required data, reducing the number of server requests.

  • Data Structure:

    • REST: Returns fixed data structures defined by the server.

    • GraphQL: Allows clients to specify the exact structure and fields they need.

  • Overfetching/Underfetching:

    • REST: Often results in overfetching (fetching more data than needed) or underfetching (requiring multiple requests for complete data).

    • GraphQL: Clients only fetch the data they request, avoiding both overfetching and underfetching.

  • Versioning:

    • REST: Typically requires versioned URLs or headers to manage changes in the API.

    • GraphQL: Avoids the need for versioning by allowing clients to request the exact data shape they need.

  • Community and Ecosystem:

    • REST: More mature and widely used with a larger ecosystem.

    • GraphQL: Gaining popularity rapidly with a growing ecosystem.

Do a GraphQL transaction

Using the request function, you can do a transaction on an existing GraphQL API.

There are multiple parameters at play for this request:

ParameterTypeDefaultDescription

url

String

The GraphQL API endpoint.

document

String

Your GraphQL request. Either a query or a mutation in GraphQL notation.

variables

Object

Optionally provide variables with this parameter.

headers

Object

Any header key-value pairs (e.g. for authorization).

Last updated

#355:

Change request updated