Giter VIP home page Giter VIP logo

Comments (7)

wincent avatar wincent commented on May 4, 2024 2

The problem is that after reading this section there is no example or other hint on the shape in which the operation's name should be specified or where to look up the spec. It would be nice to be pointed to somewhere in this section.

Good point, @martinheidegger. Would you like to submit a PR that adds a (probably small) example?

from graphql.github.io.

stubailo avatar stubailo commented on May 4, 2024 2

Operation name is a "cosmetic" name for this particular query, much like a function name in JavaScript. So:

{ me { username }}

Is like an anonymous function:

(function () {
  console.log('hello');
})()

Here's a query with an operation name:

query MeQuery {
  me { username }
}

That's like a named function:

function printGreeting() {
  console.log('hello');
}

printGreeting();

Basically it's a string you can use to refer to that function in your code, developer tools, logs, stack traces etc.

One of the most useful uses for it is in your server-side logging you can use that name to identify which queries take a long time, instead of having to look at the entire query string.

from graphql.github.io.

wincent avatar wincent commented on May 4, 2024 1

I guess a bug in GraphiQL?

Sounds like it could be. If you can still repro on the latest release (0.9.1), please report it over on the GraphiQL issues page.

from graphql.github.io.

stubailo avatar stubailo commented on May 4, 2024

I agree with this - that section introduces a lot of new concepts at the same time and should probably do that incrementally.

from graphql.github.io.

martinheidegger avatar martinheidegger commented on May 4, 2024

@wincent Sorry, but I havn't figured out how it is supposed to work yet.

from graphql.github.io.

idibidiart avatar idibidiart commented on May 4, 2024

@stubailo a funny thing I ran into just now that's confusing m noob brain:

when I don't use "query" as in "query { ... " and instead use just "{ ... " GraphiQL returns an error saying it "Unknown operation named "null""

If I use "query { ..." it works just fine, but if I then remove "query" and re-evaluate it works, too, but not after I refresh the GraphiQL page (then it requires 'query' qualifier again or it produces the aforementioned error.

I guess a bug in GraphiQL?

from graphql.github.io.

stubailo avatar stubailo commented on May 4, 2024

By the way, I wrote a post about this recently: https://dev-blog.apollodata.com/the-anatomy-of-a-graphql-query-6dffa9e9e747

If someone has time, please send some PRs to GraphQL.org with content lifted from that post!

from graphql.github.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.