Skip to content

feat : add graphql client #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 25, 2025
Merged

Conversation

mufthi6192
Copy link
Contributor

Hasil Testing :
Screen Shot 2025-06-24 at 10 26 37

Rencana Implementasi Trait :
`<?php

/**

declare(strict_types=1);

namespace App\Models\Dtos;

use Spotlibs\PhpLib\Dtos\GraphQLQueryBuilder;
use Spotlibs\PhpLib\Dtos\TraitDtos;

/**

  • ModelAnalyticPreedaFlowcaNonbriVomQuery

  • GraphQL query DTO for Model Analytic Preeda Flowca Non BRI VOM

  • @category DataClass

  • @Package Dtos

  • @author Mufthi Ryanda mufthi.ryanda@icloud.com

  • @license https://mit-license.org/ MIT License

  • @link https://github.com/
    */
    class ModelAnalyticPreedaFlowcaNonbriVomQuery
    {
    use TraitDtos;
    use GraphQLQueryBuilder;

    /**

    • Get available GraphQL query fields
    • @return array
      */
      protected function getQueryFields(): array
      {
      return [
      'acctnoSender',
      'amountTrxOffusBin',
      'bankLeads',
      'cifnoSender',
      'degreeLeads',
      'flowcaScore',
      'idPipeline',
      'isPtCv',
      'kancaPn',
      'kanwilPn',
      'kemungkinanAlamat',
      'kemungkinanBranch',
      'kemungkinanKanca',
      'kemungkinanKanwil',
      'kemungkinanKodepos',
      'kemungkinanUker',
      'namaPipeline',
      'norekLeads',
      'pnDanaSender',
      'snameLeads',
      'snameSender',
      'ukerPn'
      ];
      }

    /**

    • Get GraphQL query name
    • @return string
      */
      protected function getQueryName(): string
      {
      return 'ModelAnalytic_preedaFlowcaNonbriVom';
      }

    /**

    • Get GraphQL operation name
    • @return string
      */
      protected function getOperationName(): string
      {
      return 'modelAnalytic_preedaFlowcaNonbriVom';
      }
      }
      `

Rencana Implementasi Client :
`
$router->get('/graphql', function () use ($router) {

// Build Client
$client = new GraphQLClient('http://secret.com/gateway/apiDatahubGraphql/1.0/graphql');
$client->setBasicAuth('secret', 'secret');
$client->setHeaders(['X-DATAHUB-BRANCH' => 'secret']);

// Build Query
$queryDto = new ModelAnalyticPreedaFlowcaNonbriVomQuery();
$queryDto->select('acctnoSender', 'cifnoSender');
$query = $queryDto->toGraphQLQueryString();

// Response
$response = $client->query($query);
$response_header = $response->getHeaders();
$response_body = json_decode((string)$response->getBody());
dd($response_header,$response_body);

});
`

@mufthi6192 mufthi6192 requested a review from m45adiwinata June 24, 2025 03:29
Copy link
Contributor

@m45adiwinata m45adiwinata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add unit test and fix linter

@m45adiwinata m45adiwinata merged commit 68e3419 into master Jun 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants