This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const EXCHANGE_RATES = gql` | |
{ | |
rates(currency: "USD") { | |
currency | |
rate | |
name @client | |
} | |
} | |
` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// imports... | |
import Rates from './Rates' | |
// client = ... | |
function App() { | |
return ( | |
<ApolloProvider client={client}> | |
... | |
<Rates /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { useQuery } from '@apollo/react-hooks' | |
import { gql } from 'apollo-boost' | |
const EXCHANGE_RATES = gql` | |
{ | |
rates(currency: "USD") { | |
currency | |
rate | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
function App() { | |
return ( | |
<div> | |
<h1>Apollo Mocks Demo 🚀</h1> | |
</div> | |
) | |
} | |
export default App |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yarn add apollo-boost @apollo/react-hooks graphql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post = Post.new | |
post.user = nil | |
post.save!(validate: false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddUserReferenceToPosts < ActiveRecord::Migration[5.1] | |
def change | |
add_reference :posts, :user, foreign_key: true | |
end | |
end |