Skip to content

Commit fc4bc84

Browse files
committed
Adding incomplete SearchForm
1 parent 9046125 commit fc4bc84

File tree

6 files changed

+119
-41
lines changed

6 files changed

+119
-41
lines changed

client/src/App.vue

+29-18
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
<template>
2-
<div id="app">
3-
<nav class="navbar is-primary" role="navigation" aria-label="main navigation">
4-
<div class="container">
5-
<div class="navbar-brand">
6-
<router-link class="navbar-item" to="/signup">Blog App</router-link>
7-
8-
<button class="button navbar-burger">
9-
<span></span>
10-
<span></span>
11-
<span></span>
12-
</button>
13-
</div>
14-
</div>
15-
</nav>
16-
<router-view/>
17-
</div>
18-
2+
<div id="app">
3+
<Header/>
4+
<SearchForm/>
5+
</div>
196
</template>
207

218
<script>
9+
import Header from './components/layout/Header';
10+
import SearchForm from './components/SearchForm';
11+
// import SearchResults from './components/SearchResults';
12+
// import Pagination from './components/Pagination';
13+
14+
// <SearchResults
15+
// v-if="videos.length > 0"
16+
// v-bind:videos="videos"
17+
// v-bind:reformattedSearchString="reformattedSearchString"
18+
// />
19+
// <Pagination
20+
// v-if="videos.length > 0"
21+
// v-bind:prevPageToken="api.prevPageToken"
22+
// v-bind:nextPageToken="api.nextPageToken"
23+
// v-on:prev-page="prevPage"
24+
// v-on:next-page="nextPage"
25+
// />
26+
2227
export default {
23-
name: 'app'
28+
name: 'app',
29+
components: {
30+
Header,
31+
SearchForm,
32+
// SearchResults,
33+
// Pagination
34+
},
2435
}
2536
</script>

client/src/components/SearchForm.vue

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<template>
2+
<div>
3+
<div>
4+
Search
5+
<!-- 1 -->
6+
<input type="text" v-model="project" class="form-control" placeholder="search...">
7+
<div v-if="error">{{ error }}</div>
8+
</div>
9+
</div>
10+
11+
</template>
12+
13+
<script>
14+
15+
// 2
16+
import { SEARCH_QUERY } from '@/graphql'
17+
18+
export default {
19+
name: 'Search',
20+
data () {
21+
return {
22+
provider: 'GITHUB',
23+
project: '',
24+
error: null,
25+
}
26+
},
27+
apollo: {
28+
gitRepos: {
29+
query: SEARCH_QUERY,
30+
variables () {
31+
return {
32+
provider: this.provider,
33+
project: this.project,
34+
quantity: 100,
35+
}
36+
},
37+
options: () => ({ errorPolicy: 'all' }),
38+
skip () {
39+
return !this.project
40+
},
41+
error(error) {
42+
this.error = error.message;
43+
},
44+
debounce: 500,
45+
errorPolicy: 'all',
46+
}
47+
}
48+
}
49+
</script>
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<template>
2+
<div class="pad-15-hor pad-15-ver header">
3+
<div> <img src="@/assets/logo.png" width="25px"> Git Search </div>
4+
<div> <i class="fas fa-bars"></i> </div>
5+
</div>
6+
</template>
7+
<script>
8+
export default {
9+
name:"Header"
10+
}
11+
</script>
12+
<style>
13+
</style>
14+

client/src/graphql.js

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import gql from 'graphql-tag'
22

3-
export const SIGNUP_MUTATION = gql`mutation SignupMutation($username: String!, $email: String!, $password: String!) {
4-
createUser(
5-
username: $username,
6-
email: $email,
7-
password: $password
8-
) {
9-
id
10-
username
11-
email
12-
}
13-
}`
3+
export const SEARCH_QUERY = gql`query gitRepos($provider: Providers!, $project: String!, $quantity: Int!) {
4+
gitRepos(provider: $provider, project: $project, quantity: $quantity) {
5+
items {
6+
id
7+
repo
8+
author
9+
host
10+
htmlUrl
11+
tagsUrl
12+
cloneUrl
13+
description
14+
}
15+
}
16+
}`
17+

client/src/main.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
import { ApolloClient } from 'apollo-client'
2+
import { ApolloLink } from 'apollo-link'
23
import { HttpLink } from 'apollo-link-http'
4+
import { onError } from "apollo-link-error";
35
import { InMemoryCache } from 'apollo-cache-inmemory'
46
import VueApollo from 'vue-apollo'
57
import Vue from 'vue'
68
import App from './App.vue'
79
import router from './router'
10+
import store from './store'
811
import config from './config/config'
912

13+
const errorLink = onError(e => console.log(e));
14+
1015
const httpLink = new HttpLink({
1116
// URL to graphql server, you should use an absolute URL here
12-
uri: `${config.HOST}/graphql`
17+
uri: `${config.HOST}/graphql`,
1318
})
1419

1520
// create the apollo client
1621
const apolloClient = new ApolloClient({
17-
link: httpLink,
18-
cache: new InMemoryCache()
22+
link: ApolloLink.from([errorLink, httpLink]),
23+
cache: new InMemoryCache(),
1924
})
2025

2126
// install the vue plugin
2227
Vue.use(VueApollo)
2328

2429
const apolloProvider = new VueApollo({
25-
defaultClient: apolloClient
30+
defaultClient: apolloClient,
2631
})
2732

2833
Vue.config.productionTip = false
@@ -31,6 +36,7 @@ Vue.config.productionTip = false
3136
new Vue({
3237
el: '#app',
3338
router,
39+
store,
3440
apolloProvider,
3541
template: '<App/>',
3642
components: { App },

client/src/router/index.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import Vue from 'vue'
22
import VueRouter from 'vue-router'
3-
import SignUp from '@/components/SignUp.vue'
43

54
Vue.use(VueRouter)
65

7-
const routes = [
8-
{
9-
path: '/signup',
10-
name: 'SignUp',
11-
component: SignUp
12-
},
13-
]
6+
const routes = []
147

158
const router = new VueRouter({
9+
mode: 'history',
1610
routes
1711
})
1812

0 commit comments

Comments
 (0)