Skip to content

Instantly share code, notes, and snippets.

View kamilkisiela's full-sized avatar
🕶️
Kamil Kisiela

Kamil Kisiela kamilkisiela

🕶️
Kamil Kisiela
View GitHub Profile
import { QueryResolvers } from ‘./generated/graphql’;
import { getPosts } from ‘./posts’;
const Query: QueryResolvers.Resolvers = {
posts() {
return getPosts();
}
}
import { ObjectID } from 'mongodb';
export interface UserDbObject {
_id: ObjectID;
profile {
credentials: {
username: string;
};
};
email?: string | null;
type User @entity {
 id: String @id
 profile: Profile! @embedded
 email: @column
 photos: [Photo] @link
}
type Profile @embedded {
 fullName: String
}
import { ObjectID } from 'mongodb';
export interface UserDbObject {
 _id: ObjectID;
 profile: ProfileDbObject;
 photos: [ObjectID];
 email?: string | null;
}
export interface ProfileDbObject {
type User @entity(additionalFields: [
 { path: "services.login.token", type: "string" }
]) {
 id: String @id
 email: @column
}
import { state, mutation, update, effect } from '@loona/react';
const defaults = {
books: [
{
id: generateID(),
title: 'Book A',
__typename: 'Book',
},
],
import React from 'react';
import { Mutation } from '@loona/react';
export default props => (
<Mutation mutation={ADD_BOOK}>
{addBook => (
<button onClick={() => addBook({
variables: {
title: props.title
},
const bookFragment = gql`
fragment book on Book {
id
title
liked
}
`;
const LIBRARY = gql`
query library {
import React from 'react';
import { Query } from '@loona/react';
import { List } from '../common/List';
const ALL_BOOKS = gql`
query GetAllBooks {
books @client {
id
title
import {Mutation} from '@loona/react';
const ADD_BOOK = gql`
mutation AddNewBook($title: String!) {
addBook(title: $title) @client {
id
title
}
}
`;