What is the meaning of naming queries and mutations in GraphQL?

Sorry for the naive question, but I was looking for an answer everywhere, and everything I found is either vague or meaningless for me. Take this example from the GraphQL specification:

query getZuckProfile($devicePicSize: Int) {
  user(id: 4) {
    id
    name
    profilePic(size: $devicePicSize)
  }
}

What is the point of calling this query getZuckProfile? I saw something about GraphQL documents containing several operations. Does the naming request affect the returned data somehow? I would check it myself, but I don’t have a server and a dataset with which I could easily experiment. But it would be nice if something in some document could clarify this - for now, all the examples are super simple single queries, or queries that are named, but do not explain why they are (except for “cool here”) what can you do. ") What are the benefits of naming requests that I don’t have when I submit one anonymous request request?

Also, regarding mutations, I see in the spec:

mutation setName {
  setName(name: "Zuck") {
    newName
  }
}

setName . ? , , , :

mutation {
  setName(name: "Zuck") {
...

, ? , , , , ? - , , , .

+18
2

. , ( / ).

, , GraphQL ( ):

{
  user(id: 4) {
    id
    name
    profilePic(size: 200)
  }
}

, .

, query ( mutation), . , , GraphQL.

EDIT

@orta , . GraphQL, .

+12

, , . , .

:

query getArtwork($id: String!) {
  artwork(id: $id) {
    title
  }
}

Artsy GraphQL API

, , , - , . , , .

+2

Source: https://habr.com/ru/post/1618051/


All Articles