Error on graphql query

hi, i am trying to add this graphql query in a graphql node in n8n but i am ending up with a syntax error:

Invalid Syntax : There are more tokens in the query that have not been consumed offending token ‘$’ at line 1 column 1495

query GetDashBoardData(
$source: SourceEnum!
$twoWeeksFilter: OrderDataFilter
$oneDayFilter: OrderDataFilter
$oneMonthFilter: OrderDataFilter
$oneWeekFilter: OrderDataFilter
$startDate: String!
$endDate: String!
) {
ordersForPastTwoWeeks: allOrders(source: $source, filter: $twoWeeksFilter) {
…OrderShort_part
}
ordersForPastMonth: allOrders(source: $source, filter: $oneMonthFilter) {
…OrderShort_part
customer {
…CustomerInitials_part
}
}
ordersForPastWeek: allOrders(source: $source, filter: $oneWeekFilter) {
…OrderShort_part
customer {
…CustomerInitials_part
}
}
orderStatisticsForPastMonth: orderStatistics(
source: $source
startDate: $startDate
endDate: $endDate
) {
date
totalSales
}
monthlySales: orderStatisticsByMonth(source: $source) {
date
ordersNumber
}
ordersForDay: allOrders(source: $source, filter: $oneDayFilter) {
…OrderShort_part
customer {
…CustomerInitials_part
}
}
ordersToShip: allOrders(source: $source, filter: { orderState: { sign: EQ, value: 1 } }) {
orderDataId
}
bestSellers: top10OrderedProductsForMarketplace(source: $source) {
code
title
}
auctionReports: getBidAuctionsReport {
…BidAuctionReport_part
}
recentOrders: orders(source: $source, beginIndex: 0, maxResult: 10) {
customer {
firstName
lastName
email
}
createTime
}
inventoriesWithNoStock: getInventoriesTotal(filter: { inStock: { sign: EQ, value: 0 } })
}
${OrderShortFragment}
${CustomerInitialsFragment}
${BidAuctionReportFragment}

OrderShortFragment =
fragment OrderShort_part on OrderData {
orderDataId
orderId
vendorId
createTime
updateTime
total
orderStateValue
orderState
payTotal
commission
}

CustomerInitialsFragment =
fragment CustomerInitials_part on Customer {
id
firstName
lastName
email
}

BidAuctionReportFragment =
fragment BidAuctionReport_part on BidAuctionReport {
paidPercent
unpaid
raised
products
bidAuction {
auctionCode
}
}

i am pretty sure our query is correct but it seems the node cannot render a proper json output for this

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @josephavetti,

To be honest you may be better off using the HTTP Request node for GraphQL at the moment. If you did want to use the GraphQL node it will expext the GraphQL Raw query to be

{
  "query": "your_query"
}

So something like…

query getAllTeas{
  teas{
    name,
    id
  }
}

Would become

{
  "query": "query getAllTeas{ teas{ name, id }}"
}

Which can be sent to https://graphql-teas-endpoint.netlify.app/ to get a list of teas

We have a dev ticket open to make the graphQL node better but I am not sure when we will pick this up but hopefully it will be soon.

1 Like

thanks, if i am going to use the http request node, do I need to convert the query to JSON?

Hey @josephavetti,

Yeah there is a good chance you will need to.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.