Skip to content

Commit

Permalink
Day3
Browse files Browse the repository at this point in the history
  • Loading branch information
vnovick committed Feb 14, 2019
1 parent e096110 commit f6824a4
Show file tree
Hide file tree
Showing 12 changed files with 2,709 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*/**/node_modules
.idea
livecoding
177 changes: 176 additions & 1 deletion Day3/LessonNotes.md
Original file line number Diff line number Diff line change
@@ -1 +1,176 @@
# Lesson Notes will be published at the end of Day3
# Directives

`@include`
include field if argument is true
`@skip`
skip field if argument is true


```
query getPosts($includeUser: Boolean!) {
posts(order_by:{ timestamp: desc}) {
id
subject
content
user @include(if: $includeUser){
firstName
lastName
}
timestamp
}
}
```

# Fragments

```
fragment userWithAvatar on users {
firstName
lastName
profile {
avatarUrl
}
}
fragment userFragment on posts {
user {
...userWithAvatar
comments {
message
}
}
}
fragment postsData on posts {
id
subject
content
}
query getPosts($includeUser: Boolean!) {
posts(order_by:{ timestamp: desc}) {
...postsData
...userFragment @include(if: $includeUser)
timestamp
}
}
subscription subPosts {
posts {
...postsData
...userFragment
}
}
```

# Inline Fragments

```
query HeroForEpisode($ep: Episode!) {
hero(episode: $ep) {
name
... on Droid {
primaryFunction
}
... on Human {
height
}
}
}
```


# Type System

## GraphQLObjectType
a type with some fields
## Build in scalar types:

Int: A signed 32‐bit integer.
Float: A signed double-precision floating-point value.
String: A UTF‐8 character sequence.
Boolean: true or false.
ID: The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human‐readable.

> You can define your own scalar types
```
scalar Date
```

## Enums

```
enum Episode {
NEWHOPE
EMPIRE
JEDI
}
```

## Lists
`[String]`

## Non-Null
adding `!` in Schema definition tells us that type is not null


# Introspection

```
query {
__schema {
types {
name
}
}
}
```

# Defining your schema

```
type Query {
posts: [Post!]!
}
type Mutation {
createDraft(title: String!, content: String, author: String!): Post
}
```

Documenting

```
"Description for the type"
type Post {
"""
Description for field
"""
```

# Tooling
[GraphiQL](https://github.com/graphql/graphiql)

[GraphCMS](https://graphcms.com/)

[GraphQL Playground](https://github.com/prisma/graphql-playground)

[Hasura](hasura.io)

[GraphQL Docs](https://graphql-docs.com)

# Setting up basic server

[graphql-yoga](https://github.com/prisma/graphql-yoga)
[apollo-server](https://www.apollographql.com/docs/apollo-server/)
[graphql-express](https://github.com/graphql/express-graphql)


## For subscriptions check
[graphql-subscriptions](https://github.com/apollographql/graphql-subscriptions)

# Authentication

Loading

0 comments on commit f6824a4

Please sign in to comment.