GroceriStar / playing-with-graphql

4 stars 4 forks source link

[GraphQL Basics course] [Main Task] [Alejandro] #6

Open atherdon opened 6 years ago

atherdon commented 6 years ago

Please start by reading the documentation, related to GraphQL: https://www.howtographql.com/ After reading each chapter - please briefly explain to me here what did you learn from it. Format(example):

Chapter 1: Intro (https://graphql.org/learn/)

"It's covering the basics of graphql" Questions: "How i can run it at my local PC"?


atherdon commented 6 years ago

@xFloki it's your task

atherdon commented 6 years ago

please follow this link: https://github.com/GroceriStar/playing-with-graphql/invitations

atherdon commented 6 years ago

this is your repo for react course : https://github.com/GroceriStar/react-intern-only-27 @xFloki

xFloki commented 6 years ago

Chapter 1: Intro (https://graphql.org/learn/)

Overview of what GraphQL is ( query language not tied to any specific database or storage ) and how to create a service in which wee need to define types and fields for those types and then provide function for each of those fields. On receiving queries they are first checked to ensure they only refer to types and fields defined.

Questions: I don't really understand how the functions are associated a specific field but I guess i'll be explained further on.

xFloki commented 6 years ago

https://github.com/GroceriStar/playing-with-graphql/issues/6#issuecomment-403096889

Awesome! I'll check it out later, Thanks!

xFloki commented 6 years ago

Chapter 2: Queries and Mutations (https://graphql.org/learn/queries/)

Fields (https://graphql.org/learn/queries/#fields)

Essentially GraphQL is about asking for specific fields on objects. fields can be object and we decide what field of the object we want to fetch preventing overfetching and making it easy to get any specific field. GraphQL queries look the same for both single items or lists of items, we know which one to expect based on what is indicated in the schema.

Questions: Is there any easy way to get all fields of a object instead of having to declare every field on the query ?

Arguments (https://graphql.org/learn/queries/#arguments)

Every field and nested object can get its own set of arguments, we can even pass arguments into scalar fields, to implement data transformations once on the server.

Aliases (https://graphql.org/learn/queries/#aliases)

The result object fields match the name of the field, if we want to query the same field multiple times with different parameters on the same request wee need these aliases to avoid object naming conflicts.

Fragments (https://graphql.org/learn/queries/#fragments)

A fragment is basically a reusable piece of query ( In GraphQL, is very common the need to query for the same data fields in different queries ).

Operation Name (https://graphql.org/learn/queries/#operation-name)

The operation type is either query, mutation, or subscription and describes what type of operation you're intending to do, it's mostly required The operation name is a meaningful and explicit name for your operation, not always required but his use is encouraged becase it make easier debugging.

Variables (https://graphql.org/learn/queries/#variables)

In case parameters of our query are dynamic we use variables. In order to this variables to work we need to follow three steps:

Variables argumentes can be required by setting ! after type when we declare the variables accepted by our query: query HeroNameAndFriends($episode: Episode!) Variables can also have a default values by adding the default value after the type declaration

Directives (https://graphql.org/learn/queries/#directives)

Directives are used to dynamically change the structure and shape of our queries using variables. The core GraphQL specification includes exactly two directives:

Mutations (https://graphql.org/learn/queries/#mutations)

Same as in REST Api where the convention is not to do any modification on GET requests, here in GraphQL there's a convention that any operations that cause writes should be sent explicitly via a mutation operation type. Important detail -> mutation fields run in series, one after the other.

Inline Fragments (https://graphql.org/learn/queries/#inline-fragments)

We can use inline fragments in case a query field return multiple types with different fields between them and we want to retrieve different information depending on which type was returned. Also there is a meta field called __typename which allow us to get at any point in a query name of the object type at that point.

atherdon commented 6 years ago

will reply soon :_

atherdon commented 6 years ago

@xFloki my github account was banned, this is why i was not able to reply to you before. tell me if we can continue - i think it's time to have more practice tasks, working on server that we're building

atherdon commented 5 years ago

@xFloki Hi Alejandro, we/re restarting our work on graphql server, if you interested to join us - buzz me