Skip to Content
API ReferenceAPI Module Integration

API Module

The API module provides GraphQL and REST API endpoints for platform integration.

Features

This module includes essential features for api management.

Usage

The API module is registered automatically when you include it in your application setup. Controllers and schemas are now contributed during component build:

func (c *component) Build(builder *composition.Builder) error { if !builder.Context().HasCapability(composition.CapabilityAPI) { return nil } // ContributeControllersFunc resolves each constructor parameter from // the container by type. application.Application is provided by the // engine automatically. composition.ContributeControllersFunc(builder, func( app application.Application, userService *services.UserService, uploadService *services.UploadService, authService *services.AuthService, ) []application.Controller { return []application.Controller{ controllers.NewGraphQLController(app, userService, uploadService, authService), } }) composition.ContributeSchemas(builder, func(*composition.Container) ([]application.GraphSchema, error) { return []application.GraphSchema{{ Value: schema, BasePath: "/api", }}, nil }) return nil }
Last updated on