Automatic schema generation

Gloo Edge can automatically discover API specifications and create GraphQL schemas. The generated GraphQLApi includes the configuration for REST or gRPC resolvers and schema definitions for the types of data to return to GraphQL queries.

Gloo Edge supports two modes of discovery: allowlist and blocklist. For more information about these discovery modes, see the Function Discovery Service (FDS) guide.

Allowlist mode

In allowlist mode, discovery is enabled manually for only specific services by labeling those services with the function_discovery=enabled label. This mode gives you full manual control over which services you want to expose as GraphQL services.

  1. Label services for discovery.

    kubectl label service <service_name> discovery.solo.io/function_discovery=enabled
    
  2. Allow automatic generation of GraphQL schemas by enabling FDS discovery in allowlist mode.

    kubectl patch settings -n gloo-system default --type=merge --patch '{"spec":{"discovery":{"fdsMode":"WHITELIST"}}}'
    

Blocklist mode

In blocklist mode, discovery is enabled for all supported services, unless you explicitly disable discovery for a service by using the function_discovery=disbled label.

  1. Label services that you do not want to be discovered.

    kubectl label service <service_name> discovery.solo.io/function_discovery=disabled
    
  2. Allow automatic generation of GraphQL schemas by enabling FDS discovery in blocklist mode.

    kubectl patch settings -n gloo-system default --type=merge --patch '{"spec":{"discovery":{"fdsMode":"BLACKLIST"}}}'
    

Verifying automatic schema generation

You can verify that OpenAPI specification discovery is enabled by viewing the GraphQL custom resource that was automatically generated for your service.

kubectl get graphqlapis -n gloo-system
kubectl get graphqlapis <api_name> -o yaml -n gloo-system

For more information about the contents of the generated GraphQL schema, see the schema configuration documentation.