Skip to content

Migrating from v1 Recipes

To migrate a v1 recipe to a v2 recipe, only two things must be done:

  1. Migrate each configuration attribute to use the API v2 entities instead of the API v1 entities.
  2. Change the version attribute from 1 to 2.

The names of the top-level attributes in the YAML file (version, title, contributor, etc.) remain the same.

Example

The following demonstrates migrating the Data Enrichment with Webhooks recipe from v1 to v2. The API v1 entities must be replaced with API v2 entities. For example, the ingestStreams attribute is an array of Ingest Stream Configuration objects in v1, but an array of Quine Ingest Configuration objects in v2.

version: 1
title: Data Enrichment with Webhooks
contributor: https://github.com/mastapegs
summary: Stream numbers into graph and notify HTTP endpoint to enrich graph
description: |-
  This recipe will stream numbers into the graph and stream them out to an HTTP endpoint, which will
  then calculate the factors of those numbers, and create relationships between the numbers and their
  factors.
ingestStreams:
  - type: NumberIteratorIngest
    startAtOffset: 1
    ingestLimit: 13
    format:
      type: CypherLine
      query: |-
        WITH toInteger($that) AS number
        MATCH (n) WHERE id(n) = idFrom("Number", number)
        SET n:Number, n.number = number
standingQueries:
  - pattern:
      type: Cypher
      mode: DistinctId
      query: |-
        MATCH (n:Number)
        WHERE n.number IS NOT NULL
        RETURN DISTINCT id(n) AS id
    outputs:
      log-to-console:
        type: CypherQuery
        query: |-
          MATCH (n:Number)
          WHERE id(n) = $that.data.id
          RETURN n.number AS number, $that.data.id AS id
        andThen:
          type: PrintToStandardOut
      post-to-webhook:
        type: CypherQuery
        query: |-
          MATCH (n:Number)
          WHERE id(n) = $that.data.id
          RETURN n.number AS number, $that.data.id AS id
        andThen:
          type: PostToEndpoint
          url: http://127.0.0.1:3000/webhook
nodeAppearances:
  - predicate:
      propertyKeys: []
      knownValues: {}
      dbLabel: Number
    label:
      type: Property
      key: number
      prefix: "Number: "
quickQueries: []
sampleQueries:
  - name: Return all Number nodes
    query: MATCH (n:Number) RETURN n
statusQuery: null
version: 2
title: Data Enrichment with Webhooks
contributor: https://github.com/mastapegs
summary: Stream numbers into graph and notify HTTP endpoint to enrich graph
description: |-
  This recipe will stream numbers into the graph and stream them out to an HTTP endpoint, which will
  then calculate the factors of those numbers, and create relationships between the numbers and their
  factors.
ingestStreams:
  - name: number-iterator                 # ingest stream must have a name
    source:
      type: NumberIterator                # type moves under source
      startOffset: 1                      # startAtOffset → startOffset
      limit: 13                           # ingestLimit → limit
    query: |-                             # query moves out of format
      WITH toInteger($that) AS number
      MATCH (n) WHERE id(n) = idFrom("Number", number)
      SET n:Number, n.number = number
standingQueries:
  - name: number-processor               # standing query must have a name
    pattern:
      type: Cypher
      mode: DistinctId
      query: |-
        MATCH (n:Number)
        WHERE n.number IS NOT NULL
        RETURN DISTINCT id(n) AS id
    outputs:                             # outputs changes from a map to an array
      - name: log-to-console             # output name moves to the `name` field
        preEnrichmentTransformation:
          type: InlineData
        resultEnrichment:
          query: |-                      # query moves under resultEnrichment
            MATCH (n:Number)
            WHERE id(n) = $that.id
            RETURN n.number AS number, $that.id AS id
          parameter: that
        destinations:                    # andThen → destinations
          - type: StandardOut            # PrintToStandardOut → StandardOut
      - name: post-to-webhook
        preEnrichmentTransformation:
          type: InlineData
        resultEnrichment:
          query: |-
            MATCH (n:Number)
            WHERE id(n) = $that.id
            RETURN n.number AS number, $that.id AS id
          parameter: that
        destinations:
          - type: HttpEndpoint           # PostToEndpoint → HttpEndpoint
            url: http://127.0.0.1:3000/webhook
nodeAppearances:
  - predicate:
      propertyKeys: []
      knownValues: {}
      dbLabel: Number
    label:
      type: Property
      key: number
      prefix: "Number: "
quickQueries: []
sampleQueries:
  - name: Return all Number nodes
    query: MATCH (n:Number) RETURN n