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 { GET_NAMES } from './queries.js' | |
import { Query } from 'react-apollo'; | |
class Names extends Component { | |
render() { | |
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,{ Component } from 'react'; | |
import ApolloClient from 'apollo-boost' | |
import { ApolloProvider } from 'react-apollo' | |
import Names from './Names' | |
import './App.css'; | |
const client = new ApolloClient({ | |
uri: 'http://localhost:8000/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 { gql } from 'apollo-boost' | |
export const GET_NAMES = gql` | |
query { | |
getnames{ | |
name | |
} | |
} | |
` |
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 { gql } = require('apollo-server-express'); | |
const schema = gql` | |
type Query { | |
getnames: [Names!], | |
} | |
type Names{ | |
id: ID!, |
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 express = require('express'); | |
const { ApolloServer } = require('apollo-server-express'); | |
const cors = require('cors'); | |
const schema = require('./graphql/schema'); | |
const resolvers = require('./graphql/resolver'); | |
const app = express(); | |
app.use(cors()); |
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 names = require('./mockdata'); | |
const resolvers = { | |
Query: { | |
getnames: () => { | |
return names; |
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
let names = | |
[ | |
{ | |
id: 0, | |
name: 'David' | |
}, | |
{ |
NewerOlder