Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

https://graphql.org/learn/

GraphQL offers a powerful way to integrate many aspects of SolarPlus and build your custom integrations with any platform.

Setting up GraphQL access via IDE

...

Code Block
{
  "name": "SolaPlus Live",
  "schemaPath": "schema.graphql",
  "extensions": {
    "endpoints": {
      "Default GraphQL Endpoint": {
        "url": "https://go.solarplus.co/graphql",
        "headers": {
          "user-agent": "JS GraphQL",
          "authorization": "Bearer ~add-token-here~"
        },
        "introspect": false
      }
    }
  }
}

Query the API

Add ID variable
{ "id": 181043 }Create your query file

Code Block
query Inventory($id: ID!) {
    Inventory(id: $id) {
        id
        name
        created
    }
}

Add argument variables, eg. ID
{ "id": 181043 }

Result:

Code Block
{
"data": {
"System": {
"id": "181043",
"name": "9.6 kW Primo Telsa",
"created": "2021-06-25 04:34:14"
}
}

...

Query as per instructions on the left hand panel:

Code Block
{ Inventory(id: 87381 ) {
  id
  name
  InventoryPricings {
    id
    item_variation_suffix
    unitPrice
  }
  
}
}
id
name
InventoryPricings {
id
item_variation_suffix
unitPrice
}}

Sample JSON result:

Code Block
languagejson
{
  "data": {
    "Inventory": {
      "id": "87381",
      "name": "Clenergy ezRack Mounting 40mm Tin",
      "InventoryPricings": [
        {
          "id": "77899",
          "item_variation_suffix": "Bracket Tin PV-ezRack",
          "unitPrice": "$2.43"
        },
        {
          "id": "77900",
          "item_variation_suffix": "Isolator Shade, 280*158*114mm",
          "unitPrice": "$8.80"
        },
        {
          "id": "77901",
          "item_variation_suffix": "Cable Clip for 2 cables",
          "unitPrice": "$0.30"
        },
        {
          "id": "77902",
          "item_variation_suffix": "PV-ezRack End Clamp - 40mm",
          "unitPrice": "$0.80"
        },
        {
          "id": "77903",
          "item_variation_suffix": "PV-ezRack Inter Clamp - 40mm",
          "unitPrice": "$2.00"
        },
        {
          "id": "77904",
          "item_variation_suffix": "Clamp Grounding PV-ezRack",
          "unitPrice": "$0.34"
        },
        {
          "id": "77905",
          "item_variation_suffix": "Eco Rail, 4200mm",
          "unitPrice": "$24.35"
        },
        {
          "id": "77906",
          "item_variation_suffix": "Splice for ECO-Rail",
          "unitPrice": "$1.80"
        }
      ]
    }
  }
}