Marmind Knowledge Base

GraphQL: Query Syntax and Example Queries

📄 Summary: What You’ll Learn in This Article

In this article, you’ll learn the basics of GraphQL query syntax and see practical examples you can try out directly in the built-in editor.

:check_mark:
  • Write a simple GraphQL query

  • Retrieve and filter data

  • Use ordering and conditions

  • Fetch related information like KPIs or custom fields


🧑‍🤝‍🧑 Who Should Read This?

:info:

This article is most useful for:

  • Anyone working with GraphQL in Marmind, especially Configurators, developers, or advanced users who want to retrieve structured data efficiently.


✔️ Prerequisites: What Should You Know Before Getting Started?

🎚️

Level: Advanced

🔑

Access required: A GraphQL endpoint in Marmind (in-built editor or API access)

  • Basic understanding of data objects in Marmind (e.g., advertising, campaigns, KPIs) is required.


Basic Query Syntax

Every GraphQL query must be wrapped inside a query { } block. This is the foundation of all queries.

Example:

query {
  # your query goes here
}

In the editor, this ensures that your request is properly structured and can be executed.


Example 1: Get a Marketing Activity by ID

This query retrieves a specific marketing activity (technical name: advertising) by its ID. It also includes the referenced advertising material type.

Query:

query getAdvertising {
  advertising(id: 35) {
    id
    name
    advertisingMaterialType {
      name
    }
  }
}

Result:

{
  "data": {
    "advertising": {
      "id": 35,
      "name": "Brochure test",
      "advertisingMaterialType": {
        "name": "Brochure"
      }
    }
  }
}

Use this when you want detailed information about one specific marketing activity.


Example 2: Filter and Order Advertising Objects

This query lists all advertisings that start with the letter “a”, orders them by name in descending order, and returns only selected attributes (name, status, color, duration).

Query:

query advertisingA {
  advertisings(
    where: { name: { startsWith: "a" } }
    order: { name: DESC }
  ) {
    nodes {
      name
      status
      color
      durationFrom
      durationTo
    }
  }
}

Result (shortened):

{
  "data": {
    "advertisings": {
      "nodes": [
        {
          "name": "A2pl - Banner - Act1",
          "status": "Draft",
          "color": null,
          "durationFrom": null,
          "durationTo": null
        },
        {
          "name": "A2pl - Advertisement - Act2",
          "status": "Draft",
          "color": null,
          "durationFrom": null,
          "durationTo": null
        }
      ]
    }
  }
}

Use this when you want to search and sort multiple items with specific filters.


Example 3: Get KPIs for an Advertising

This query retrieves the KPIs (Key Performance Indicators) of an advertising object, including their template and values.

Query:

query advertisingKpi {
  advertising(id: 36) {
    name
    keyFigures {
      template {
        name
      }
      values {
        type
        interval
        value
      }
    }
  }
}

Result (shortened):

{
  "data": {
    "advertising": {
      "name": "Advertisement",
      "keyFigures": [
        {
          "template": { "name": "CPA" },
          "values": [
            { "type": "Actual", "interval": "2020M01", "value": 400 },
            { "type": "Plan", "interval": "2020M01", "value": 350 }
          ]
        }
      ]
    }
  }
}

Use this when you want to analyze performance metrics of a campaign or activity.


Example 4: Get Campaigns Including Custom Fields

This query retrieves campaigns (called initiatives) and their custom fields, filtered for names that contain the word briefing.

Query:

query campaignsWithCustFields {
  initiatives(order: { name: ASC }) {
    totalCount
    nodes {
      id
      name
      customFields(
        where: { name: { contains: "briefing" } }
        order: { name: ASC }
      ) {
        name
        value
      }
    }
  }
}

Result (shortened):

{
  "data": {
    "initiatives": {
      "totalCount": 4,
      "nodes": [
        {
          "id": 3,
          "name": "Kampagne2",
          "customFields": [
            {
              "name": "Campaignbriefing",
              "value": "http://link.austria.info/content/docs/briefing.html"
            }
          ]
        }
      ]
    }
  }
}

Use this when you want to see custom field values attached to your campaigns.


âť“ FAQs

Do all GraphQL queries need to start with query?

Yes, unless you are using mutations (for changing data), every query must start with query { ... }.

Can I request only the fields I need?

Exactly! One of GraphQL’s strengths is that you only ask for the fields you want, making responses lightweight.

What happens if a field doesn’t exist or has no value?

You’ll get null for that field in the response instead of an error.