Chapter 5

  1. GraphQL is not intended to fully replace REST clients. It can act as a cooperative technology, so it could very well consume multiple REST APIs itself to produce graphs.
  2. A mutation is an operation that is intended to change the data in the graph in some way. We might want to add new items to the graph, update items, or delete items. It is important to remember that the mutation is just changing the graph – if the change has to be persisted to where the graph got the information from, then it is the graph's responsibility to call out to underlying services to make those changes.
  3. In order to pass a value to a subcomponent, we need to use @Input() to expose a field for binding from the parent. In our code example, we set up a Todo item like so:
@Input() Todo: ITodoItem;
  1. With GraphQL, a resolver represents an instruction on how to turn an operation into data; they are organized as a one-to-one mapping to the fields. The schema, on the other hand, represents a number of resolvers.
  2. To create a singleton, the first thing that we need to do is create our class with a private constructor. A private constructor means that the only place that we can instantiate our class is from inside the class itself:
export class Prefill {
private constructor() {}
}

The next thing we need to do is add a field to hold a reference to the class instance and then offer a public static property to access that instance. The public property will take care of instantiating the class if it's not already available so that we'll always be able to access it:

private static prefill: Prefill;
public static get Instance(): Prefill {
return this.prefill || (this.prefill = new this());
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.70.203