Skip to content

Multiple query/mutation and onComplete behavior #25

@PierrickP

Description

@PierrickP

I don't know if it is a bug or not

For this test case

test('should consider default cost with operationName', done => {
  const ast = parse(
    `
    query operationA {
      defaultCost
    }

    query operationB {
      defaultCost
    }
  `)

  const context = new ValidationContext(schema, ast, typeInfo)
  const visitor = new CostAnalysis(context, {
    maximumCost: 100,
    defaultCost: 12,
    onComplete: cost => {
      console.log('cost', cost)
      done()
    }
  })

  visit(ast, visitWithTypeInfo(typeInfo, visitor))
})

I have 2 queries, onComplete will be called 2 times
First time, cost is 12, second time 24. 🤔

After that, i use operationName, like "operationName":"operationB"
Should operationA be analysed and count in the total cost ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions