---
title: "Avro to GraphQL"
description: "Turn an Avro record schema into a GraphQL type from your AI assistant."
slug: "avro-to-graphql"
type: recipe
locale: en-US
canonical: "https://www.coremodels.io/recipe/converter/avro-to-graphql"
updatedAt: "2026-12-02T22:12:37+00:00"
last_updated: "2026-12-02T22:12:37+00:00"
---

# Avro to GraphQL

Turn an Avro record schema into a GraphQL type from your AI assistant.

You have an Avro schema. You need a GraphQL type. Use this when a GraphQL API must show the records of a stream. The output keeps the field names, the enum values, the required fields and the date-time type. The page shows the recorded output and lists what did not carry over.

- Tool: `transform_schema` on https://go.coremodels.io/mcp (read-only, sign-in required)
- From: Avro
- To: GraphQL SDL
- Recorded: 2026-12-03

## What you get

A GraphQL type with seven fields and an `OrderStatus` enum. Six fields are non-null. This is the answer CoreModels gave on 3 December 2026 for the file below.

`order.graphql`

```graphql
scalar DateTime

type Order {
  order_id: String!
  customer_id: String!
  status: OrderStatus!
  total_amount: Float!
  currency: String!
  placed_at: DateTime!
  discount_code: String
}

enum OrderStatus {
  placed
  shipped
  delivered
  returned
}
```

## What you need

- A CoreModels account with one project. Every plan starts with a 14-day free trial; a card is required to start.
- The tool uses the project only to check your access. It writes nothing.
- An assistant that speaks MCP, such as Claude Code, Claude Desktop or Cursor.
- An Avro file with one flat record.

## Run it

### 1. Connect your assistant

In Claude Code, run this command. Then sign in when it asks.

```bash
claude mcp add --transport http coremodels https://go.coremodels.io/mcp
```

Cursor, Claude Desktop and other clients: [connect guide](/mcp-server).

### 2. Save the file as `order.avsc`

Use your own file, or start with this one.

`order.avsc`

```json
{
  "type": "record",
  "name": "Order",
  "namespace": "org.example.shop",
  "doc": "A purchase order placed by a customer.",
  "fields": [
    {
      "name": "order_id",
      "type": "string",
      "doc": "Order number printed on the receipt."
    },
    {
      "name": "customer_id",
      "type": "string",
      "doc": "The customer who placed the order."
    },
    {
      "name": "status",
      "doc": "Where the order is now.",
      "type": {
        "type": "enum",
        "name": "OrderStatus",
        "symbols": ["placed", "shipped", "delivered", "returned"]
      }
    },
    {
      "name": "total_amount",
      "doc": "Order total, tax included.",
      "type": {
        "type": "bytes",
        "logicalType": "decimal",
        "precision": 12,
        "scale": 2
      }
    },
    {
      "name": "currency",
      "type": "string",
      "doc": "ISO 4217 currency code."
    },
    {
      "name": "placed_at",
      "doc": "When the customer placed the order.",
      "type": {
        "type": "long",
        "logicalType": "timestamp-millis"
      }
    },
    {
      "name": "discount_code",
      "type": ["null", "string"],
      "default": null,
      "doc": "Code used at checkout, if any."
    }
  ]
}
```

### 3. Ask for the conversion

```text
Use the CoreModels transform_schema tool to convert order.avsc from avro to graphql. Pass the whole file as sourceSchema and again as targetHintSchema. Use any project from list_projects. Save the result as order.graphql, then list every entry in lossiness.
```

Your assistant calls `transform_schema` with these arguments. The file goes in twice: once as the source, once as the hint the mapping matches against. Without the hint the tool refuses the call.

`transform_schema`

```json
{
  "graphProjectId": "<your project id>",
  "sourceFormat": "avro",
  "sourceSchema": "<contents of order.avsc>",
  "targetFormat": "graphql",
  "targetHintFormat": "avro",
  "targetHintSchema": "<contents of order.avsc>"
}
```

## What did not carry over

- We tested one flat record. Nested records and lists are not tested on this page.

CoreModels reported these changes with the answer:

- `Element[Order.total_amount]`: Avro decimal precision/scale not modelled; approximated as Double.

We compared the two files ourselves and also found:

- Descriptions. Each field has a description in the input. The output has none.
- The namespace, package or schema id of the input file.

Compare your own files too. A different file can lose other things.

## Check it yourself

Build the schema with graphql-core.

```bash
pip install graphql-core
python -c "from graphql import build_schema; build_schema(open('order.graphql').read()); print('valid SDL')"
```

## Same file, other formats

- [Avro to JSON Schema](/recipe/converter/avro-to-jsonschema)
- [Avro to PostgreSQL DDL](/recipe/converter/avro-to-sql)
- [Avro to Protobuf](/recipe/converter/avro-to-protobuf)
- [Avro to ODCS v3 data contract](/recipe/converter/avro-to-odcs)

[Start building](https://www.coremodels.io/start)

14-day free trial. Builder $49/mo after the trial. Cancel any time.

## Sitemap

- [Sitemap in markdown](https://www.coremodels.io/sitemap.md)
