import {isArr} from "licia";

const information = {
  debug: true,
  baseUrl: 'http://localhost:8080',
}

export function amisRender(target, amisJson) {
  let amisJsonObject = amisJson(information)
  if (information.debug) {
    console.log(amisJsonObject)
  }
  amisRequire('amis/embed').embed(
    target,
    amisJsonObject,
    information,
    {
      theme: 'antd',
      enableAMISDebug: information.debug,
    },
  )
}

function parseEdges (edges) {
  if (isArr(edges)) {

  }
}

export function amisElideGraphQLAdaptor(payload, response, api, context) {
  // console.log(payload, response, api, context)
  let result = []
  console.log(payload)
  if (payload.data) {
    let items = payload.data[Object.keys(payload.data)[0]]['edges']
    for(let item of items) {
      result.push(item.node)
    }
  }
  return result
}
