Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

GraphQL

GraphQL Query Constructor

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

GraphQL

GraphQL Query Constructor [only]

pascal
GraphQL: TGraphQL;
Response: TJSONObject;
...
GraphQL := TGraphQL.Create(Self);
GraphQL.Client.BaseUrl := 'https:\\api.site.io';
if GraphQL.Call(Response, Query) = 200 then
 ...
pascal
with TGraphQuery.Create('query', 'query_name') do
  begin
    AddMethod('bonuses', 
      //Args
      TGraphArgList.Create
      .AddPair('limit', 1)
      .AddPair('offset', 0)
      .AddPair('filter', TGraphArgObject.Create
        .AddPair('branch_id', 1)
        .AddPair('type', ''))
      .AddPair('sort', TGraphArgObject.Create
        .AddPair('field', 'name')
        .AddPair('order', 'asc')),
      //Fields
      TGraphFields.Create
      .AddField(TGraphField.Create('result'))
      .AddField(TGraphField.Create('items')
        .AddSub(TGraphField.Create('id'))
        .AddSub(TGraphField.Create('date')))
      .AddField(TGraphField.Create('totalCount')));
    if GraphQL.Call(Response, Query) = 200 then
     ...
    ShowMessage(Query.ToString); 
    Free;
  end;