Skip to content

Instantly share code, notes, and snippets.

@dbayarchyk
dbayarchyk / connectionSchema.gql
Last active September 22, 2019 09:32
Improve your GraphQL schema with the Relay Specification - connectionSchema.gql
type Query {
posts(after: String, before: String, first: Int, last: Int): PostConnection!
}
type PostConnection {
edges: [PostEdge!]!
pageInfo: PageInfo!
}
type PostEdge {
@dbayarchyk
dbayarchyk / PostQueryByNode.gql
Last active September 22, 2019 09:32
Improve your GraphQL schema with the Relay Specification - PostQueryByNode.gql
query ($id: ID!){
node(id: $id) {
id
... on Post {
title
}
}
}
@dbayarchyk
dbayarchyk / schema.gql
Last active September 22, 2019 09:32
Improve your GraphQL schema with the Relay Specification - schema.gql
type Query {
post(id: ID!): Post
comment(id: ID!): Comment
user(id: ID!): User
}
@dbayarchyk
dbayarchyk / nodeSchema.gql
Last active September 22, 2019 09:31
Improve your GraphQL schema with the Relay Specification - nodeSchema.gql
type Node {
id: ID!
}
type Query {
node(id: ID!): Node
}
@dbayarchyk
dbayarchyk / postPageQuery.ts
Last active October 1, 2019 10:06
GraphQL fragment-based approach to building your components - postPageQuery.ts
import gql from 'graphql-tag';
import * as Post from 'Post/fragments';
import * as Comments from 'Comments/fragments';
export default gql`
query PostPageQuery($id: ID!) {
post(id: $id) {
...Post_post
...Comments_comments
@dbayarchyk
dbayarchyk / fragments.js
Last active September 18, 2019 14:00
GraphQL fragment-based approach to building your components - Post/fragments.js
import gql from 'graphql-tag';
import * as UserInfo from 'UserInfo/fragments';
export const post = gql`
fragment Post_post on Post {
title
content
author {
...UserInfo_user
@dbayarchyk
dbayarchyk / fragments.js
Last active September 18, 2019 14:00
GraphQL fragment-based approach to building your components - Comment/fragments
import gql from 'graphql-tag';
import * as Comment from 'Comment/fragments';
export const comments = gql`
fragment Comments_comments on Post {
comments {
id
...Comment_comment
}
@dbayarchyk
dbayarchyk / PostPageQuery.gql
Last active September 18, 2019 14:00
GraphQL fragment-based approach to building your components - PostPageQuery.gql
query PostPageQuery($id: ID!) {
post(id: $id) {
title
content
author {
username
avatar
}
comments {
content
@dbayarchyk
dbayarchyk / fragments.js
Last active September 18, 2019 14:00
GraphQL fragment-based approach to building your components - Comment/fragments.ts
import gql from 'graphql-tag';
import * as UserInfo from 'UserInfo/fragments';
export const comment = gql`
fragment Comment_comment on Comment {
 content
 author {
  ...UserInfo_user
 }
@dbayarchyk
dbayarchyk / fragments.js
Last active September 18, 2019 14:00
GraphQL fragment-based approach to building your components - UserInfo/fragments.js
import gql from 'graphql-tag';
export const user = gql`
fragment UserInfo_user on User {
username
avatar
}
`;