Skip to content

Instantly share code, notes, and snippets.

View giovannibenussi's full-sized avatar

Giovanni giovannibenussi

View GitHub Profile
// imports...
import Rates from './Rates'
// client = ...
function App() {
return (
<ApolloProvider client={client}>
...
<Rates />
import React from 'react'
import { useQuery } from '@apollo/react-hooks'
import { gql } from 'apollo-boost'
const EXCHANGE_RATES = gql`
{
rates(currency: "USD") {
currency
rate
}
import React from 'react'
import ApolloClient from 'apollo-boost'
import { ApolloProvider } from '@apollo/react-hooks'
const client = new ApolloClient({
uri: 'https://48p1r2roz4.sse.codesandbox.io'
})
function App() {
return (
import React from 'react'
function App() {
return (
<div>
<h1>Apollo Mocks Demo 🚀</h1>
</div>
)
}
export default App
yarn add apollo-boost @apollo/react-hooks graphql
@giovannibenussi
giovannibenussi / App.js
Created February 23, 2019 14:28
Chat app component
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { ApolloLink } from 'apollo-link';
import { ApolloClient } from 'apollo-client';
import { ApolloProvider } from 'react-apollo'
import { HttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
import ActionCable from 'actioncable';
it "can't be saved without an user" do
post = Post.new
post.user = nil
expect { post.save!(validate: false) }.to raise_error ActiveRecord::NotNullViolation
end
post = Post.new
post.user = nil
post.save!(validate: false)
class AddUserReferenceToPosts < ActiveRecord::Migration[5.1]
def change
add_reference :posts, :user, foreign_key: true
end
end
module Validators
class Model
def self.validate!(args)
validate_presence('name', args[:name])
validate_presence('address', args[:address])
end
end
end