Queries fail if there are multiple queries

So I believe multi-operation documents are a thing in GraphQL, i.e. you can select one using an operation name. When I do this I get an error response: “An operation name is required”; but I supplied the operation name.

So in the developer’s playground I created a document with 2 queries:

query SingleBoard {
  boards(limit:1) {
    name
    
    columns {
      title
      id
      type
    }
    
    groups {
    	title
      id
    }
    
    items {
      name
      group {
        id
      }
      
      column_values {
        id
        value
        text
      }
    }
  }
}

query AllBoards {
  boards(limit:10) {
    name
  }
}

Sure enough, even though I have a drop-down under the play button in the developer’s playground that allows me to select which query I want, I get “An operation name is required” error regardless of which query I pick.

Is this a limitation of the Monday API?

Hello there @alexking !

You can do what you want by changing the syntax a little bit.

A simple example on how to accomplish this would be:

query {
  checkBoard1: boards(ids:987654321){
    id
    name
  }
  checkBoard2: boards(ids:123456789){
    id
    name
  }
}

I hope that helps!

Cheers,
Matias

Thanks Matias.

I can’t perform both queries at once, since I need the output of one (actual query is query BoardsQuery {boards (limit:100) {id name}} ) to find the board id I need for the second query. It may seem strange that I’m putting 2 queries in a document when I want to do them separately, but it’s just the way this library is structured. A simple workaround is to put each query in a separate document, and I’ll proceed that way.

(I’m doing this because I want to view a particular board, but would like to select it by name rather than id. I can’t see a way to do that, so instead I’m doing an initial query to find id and name from all boards to find the id of the board I need. That “BoardsQuery”, above, is successfully returning data.)

The next problem I have is that the library (GitHub - graphql-rust/graphql-client: Typed, correct GraphQL requests and responses in Rust) can’t compile my next query (query GetBoard {boards (ids: 560201143) {columns { title id type} items { name column_values { id value text }}}}) at all. This query runs successfully in the playground. However when compiling, I’m getting:

error[E0412]: cannot find type JSON in module super

I suspect there may be a problem with types named JSON in the schema.

Hello again @alexking,

Matias here!

Oh. I understand. In that case (where you need the response from the first one so you can use it in the second one) you will need to use two separate calls.

About the library you mentioned, it looks like it is a library that is not created or maintained by monday, so I could not say why you are encountering this issue. But if you see the same query working in your Playground, then the issue is probably on the library’s end.

Let me know if you have any other questions :slightly_smiling_face:

Cheers,
Matias