This repository was archived by the owner on Apr 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: add @vue/apollo
example implementation
#70
Closed
Closed
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
52defcb
feat: add `@vue/apollo` example implementation
danielroe f4f29d1
fix: create client once
danielroe 490564f
refactor: use nuxt plugin
danielroe 6223dec
chore: tidy
danielroe e9b202c
chore: update build scripts (#69)
pi0 d24af64
chore(deps): update all non-major dependencies (#62)
renovate[bot] d946339
chore: update package.json
danielroe 7b2d499
fix: instantiate all elements within plugin
danielroe a06a7d9
feat: use home-grown defineNuxtComponent
danielroe 1cea900
chore: revert workspace changes
danielroe 69bbbd6
Merge remote-tracking branch 'origin/main' into experiment/vue-apollo…
danielroe 2e16f7c
feat: add apollo graphql backend and add vue/apollo-composable
danielroe d7b77cc
Merge branch 'temp/apollo' into experiment/vue-apollo-example
danielroe a6b3bbc
refactor: remove express
danielroe 8f2515c
Merge remote-tracking branch 'origin/main' into experiment/vue-apollo…
danielroe 462b2c2
Merge remote-tracking branch 'origin/main' into experiment/vue-apollo…
danielroe 9e011c5
fix: workaround upstream packaging issues
danielroe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<template> | ||
<div> | ||
<NuxtPage /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { defineComponent } from 'vue' | ||
import { useApollo } from './composables/apollo' | ||
|
||
export default defineComponent({ | ||
setup () { | ||
useApollo() | ||
} | ||
}) | ||
</script> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { provide } from 'vue' | ||
import { DefaultApolloClient } from '@vue/apollo-composable' | ||
|
||
import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client/core' | ||
|
||
export function useApollo () { | ||
const httpLink = createHttpLink({ | ||
uri: 'http://localhost:3020/graphql' | ||
}) | ||
|
||
const cache = new InMemoryCache() | ||
|
||
const apolloClient = new ApolloClient({ | ||
pi0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
link: httpLink, | ||
cache | ||
}) | ||
|
||
provide(DefaultApolloClient, apolloClient) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "vue-apollo", | ||
"dependencies": { | ||
danielroe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"@apollo/client": "^3.3.14", | ||
"graphql": "^15.5.0", | ||
"graphql-tag": "^2.11.0" | ||
}, | ||
"scripts": { | ||
"dev": "../../node_modules/.bin/nu dev" | ||
danielroe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<template> | ||
<div> | ||
<div v-for="user in users" :key="user.id"> | ||
{{ users.firstname }} {{ users.lastname }} | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { defineComponent } from 'vue' | ||
danielroe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { gql } from 'graphql-tag' | ||
import { useQuery } from '@vue/apollo-composable' | ||
|
||
export default defineComponent({ | ||
setup () { | ||
const { result } = useQuery(gql` | ||
query getUsers { | ||
users { | ||
id | ||
firstname | ||
lastname | ||
} | ||
} | ||
`) | ||
|
||
return { users: result } | ||
} | ||
}) | ||
</script> |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.