Skip to content

Using GraphQL Schema

You can use the render apiproxy command to create an Apigee API proxy bundle using a template and a GraphQL schema as input.

While GraphQL schemas might not contain all the necessary details for a complete API proxy bundle, this command offers flexibility through the --set and --set-string parameters. This works similar to how values are set in Helm charts.

How it works

  • Start with Your Template

    The template, your inputs, and the schema guide the generation of an intermediate YAML configuration.

  • Access the Schema

    Use --set-graphql to access a GraphQL schema text and AST during template rendering.

  • Inject Your Values

    Use --set and --set-string to provide missing values (like target URLs) for your template.

Examples

Check out the examples/templates/graphql directory for an example of building the intermediate YAML for a GraphQL API proxy.

Here is how you would use the render apiproxy command with this example:

Create bundle zip

apigee-go-gen render apiproxy \
     --template ./examples/templates/graphql/apiproxy.yaml \
     --set-graphql schema=./examples/graphql/resorts.graphql \
     --set-string "api_name=resorts-api" \
     --set-string "base_path=/graphql" \
     --set-string "target_url=https://example.com/graphql" \
     --include ./examples/templates/graphql/*.tmpl \
     --output ./out/apiproxies/resorts.zip

Create bundle dir

apigee-go-gen render apiproxy \
     --template ./examples/templates/graphql/apiproxy.yaml \
     --set-graphql schema=./examples/graphql/resorts.graphql \
     --set-string "api_name=resorts-api" \
     --set-string "base_path=/graphql" \
     --set-string "target_url=https://example.com/graphql" \
     --include ./examples/templates/graphql/*.tmpl \
     --output ./out/apiproxies/resorts.zip