Skip to content

Instantly share code, notes, and snippets.

View AdamZaczek's full-sized avatar

Adam Żaczek AdamZaczek

View GitHub Profile
@AdamZaczek
AdamZaczek / GraphQL1.js
Last active April 25, 2017 23:12
GraphQL Getting Started Code Fragment 1
const User = new GraphQLObjectType({
name: 'User',
description: 'Represents user',
fields: () => ({
_id: { type: GraphQLString },
firstName: { type: GraphQLString },
lastName: { type: GraphQLString },
role: { type: GraphQLString }
})
});
@AdamZaczek
AdamZaczek / GraphQL2.js
Created April 25, 2017 23:12
GraphQL Getting Started Code Fragment 2
import {
GraphQLList,
GraphQLObjectType,
GraphQLSchema,
GraphQLString,
} from 'graphql';
@AdamZaczek
AdamZaczek / GraphQL3.js
Created April 25, 2017 23:13
GraphQL Getting Started Code Fragment 3
users: {
type: new GraphQLList(User),
description: 'Netguru members',
resolve: () => {
return USER.find({}, (err, res) => {
return res;
});
}
}
@AdamZaczek
AdamZaczek / GraphQL4.js
Created April 25, 2017 23:14
GraphQL Getting Started Code Fragment 4
/* eslint no-underscore-dangle: off*/
/* eslint "arrow-body-style": off */
import {
GraphQLList,
GraphQLObjectType,
GraphQLSchema,
GraphQLString,
} from 'graphql';
@AdamZaczek
AdamZaczek / GraphQL5.js
Created April 25, 2017 23:15
GraphQL Getting Started Code Fragment 5
import {
GraphQLList,
GraphQLObjectType,
GraphQLSchema,
GraphQLString,
GraphQLBoolean,
GraphQLInt
} from 'graphql';
@AdamZaczek
AdamZaczek / GraphQL6.js
Created April 25, 2017 23:16
GraphQL Getting Started Code Fragment 6
const Skill = new GraphQLObjectType({
name: 'Skill',
description: 'Represents skill',
fields: () => ({
_id: { type: GraphQLString },
name: { type: GraphQLString }
})
});
const SkillLevel = new GraphQLObjectType({
@AdamZaczek
AdamZaczek / GraphQL7.js
Created April 25, 2017 23:31
GraphQL Getting Started Code Fragment 7
const User = new GraphQLObjectType({
name: 'User',
description: 'Represents user',
fields: () => ({
_id: { type: GraphQLString },
firstName: { type: GraphQLString },
lastName: { type: GraphQLString },
role: { type: GraphQLString },
skillLevels: {
type: new GraphQLList(SkillLevel),
@AdamZaczek
AdamZaczek / GraphQL8.js
Created April 25, 2017 23:32
GraphQL Getting Started Code Fragment 8
const Skill = new GraphQLObjectType({
name: 'Skill',
description: 'Represents skill',
fields: () => ({
_id: { type: GraphQLString },
name: { type: GraphQLString },
skillLevels: {
type: new GraphQLList(SkillLevel),
description: 'Returns list of levels corrsponding to the skill. It is similar to list of grades for a certain subject in school',
resolve: (skill) => {
@AdamZaczek
AdamZaczek / GraphQL9.js
Created April 25, 2017 23:33
GraphQL Getting Started Code Fragment 9
const SkillLevel = new GraphQLObjectType({
name: 'SkillLevel',
description: 'Describes how well user knows certain skill.',
fields: () => ({
_id: { type: GraphQLString },
level: {
type: GraphQLInt,
description: 'Actual skill level, ranked from 1 to 3'
},
favorite: { type: GraphQLBoolean },
it('should return iMList once fetched', () => {
const action = {
type: FETCH_IM_LIST_SUCCESS,
payload: {
data: {
ok: true,
ims: [
{
id: "D4VAKS265",
created: 1491558944,