Skip to content

Martini Generating Services when Consuming GraphQL APIs

Martini's graphical interface streamlines the creation of services from GraphQL schemas, facilitating quick integration with GraphQL APIs. Follow these steps to generate services in Martini from a GraphQL schema.

Steps to Generate Services from a GraphQL Schema

  1. Open the Consume API Interface

    • In the Martini IDE, locate the "Consume an API" dialog by navigating to the code folder within the package where you want to generate services.
    • Click on the "Consume" button or right-click and select "Consume API" to open the service generation interface.
  2. Specify the Location for Generated Services

    • In the "Location" field, confirm or enter the path /demo-api-crm/code where the generated services will reside. This path should reflect your project's package structure.
  3. Select GraphQL Schema as the Source Type

    • In the list of source types, choose "GraphQL Schema" to indicate that you are consuming a GraphQL API.
    • The selection of this option ensures that Martini will generate the services tailored to interact with a GraphQL trigger.
  4. Provide the GraphQL Schema

    • In the "File/URL" field, input the source of your GraphQL schema. You can drag and drop a file, browse to a file location, or enter the URL of the hosted schema.
    • Click the "Browse" button to locate and upload the schema file if it's stored locally.
  5. Configure Request Logging (Optional)

    • If you wish to log requests to the Tracker for debugging or monitoring, check the "Log requests to Tracker" option. This will help you track and analyze the API requests made by the generated services.
  6. Generate the Services

    • Once all details are confirmed, click on the "Consume" button. Martini will then process the GraphQL schema and auto-generate the services for you to use in your application.

Post-Generation Steps

After generating the services, you may need to take additional steps:

  • Customize Generated Services: Review the autogenerated service components and customize queries, mutations, or subscriptions as needed to suit your business logic.
  • Test Services: Use Martini's testing tools to execute the generated services and ensure they interact with the GraphQL API as expected.
  • Secure the Services: If your GraphQL API requires authentication, ensure that the necessary headers or tokens are configured in the service settings.