Giter VIP home page Giter VIP logo

Comments (2)

DerekCuevas avatar DerekCuevas commented on June 23, 2024

1

This doc does a good job explaining/breaking down the resolver map https://www.apollographql.com/docs/graphql-tools/resolvers/#resolver-function-signature. What it names obj we named root.

The rule for the type of root is pretty simple, root is just the parent type of the field.

For example, the name resolver for the below type would have the signature: name: (root: Foo): string, because name is defined within Foo.

type Foo {
  id: ID!
  name: String!
}

https://graphql-code-generator.com is able to generate the correct type for root for every field in our schema based on what is defined by us in the SDL.

The generated types aren't the most strait forward to read through, but looking at the definition for Resolvers may help show this (https://github.com/DerekCuevas/workshop/blob/master/backend/src/index.ts#L3)

from workshop.

DerekCuevas avatar DerekCuevas commented on June 23, 2024

2

I'm not quite sure I fully understand this question. Specifically, i'm uncertain about what you mean by "since it has to resolve every field of every object". But, will try to answer, let me know if this gets at what you were wondering about.

When resolving a GraphQL query, on the server, only the field resolvers for fields specified in the query will be executed. Similarly, only data for those fields will be encoded and sent to the client.

A benefit of this, when compared to a traditional REST endpoint, would be that clients can specific only the fields they need to use. This helps clients minimize the size of the corresponding response. So if anything, I would say that GraphQL is more optimal in this regard when compared to REST.

from workshop.

Related Issues (2)

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.