Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Apollo Graphql useQuery #161

Closed
productdevbook opened this issue Dec 25, 2022 · 4 comments · Fixed by #162
Closed

feat: Apollo Graphql useQuery #161

productdevbook opened this issue Dec 25, 2022 · 4 comments · Fixed by #162
Assignees
Labels

Comments

@productdevbook
Copy link
Member

productdevbook commented Dec 25, 2022

  • New SSR code structure.
  • Adding features that are in React but not in Vue.
  • Make the code better.
  • Support all api as it seems possible.

pnpm add @huntersofbook/vue-apollo@^2.0.0-alpha.6

Query Api:
https://www.apollographql.com/docs/react/data/queries/#usequery-api

@productdevbook productdevbook self-assigned this Dec 25, 2022
@productdevbook productdevbook changed the title Apollo Graphql useQuery feat: Apollo Graphql useQuery Dec 25, 2022
@productdevbook
Copy link
Member Author

new test: "@huntersofbook/vue-apollo": "^2.0.0-alpha.6"

@productdevbook productdevbook linked a pull request Dec 26, 2022 that will close this issue
@productdevbook
Copy link
Member Author

productdevbook commented Dec 26, 2022

new createApp support

import { createApollo } from '@huntersofbook/vue-apollo'

// HTTP connection to the API
const httpLink = createHttpLink({
  // You should use an absolute URL here
  uri: 'https://countries.trevorblades.com',
})

// Cache implementation
const cache = new InMemoryCache()

// Create the apollo client
const apolloClient = new ApolloClient({
  link: httpLink,
  cache,
})

const app = createApp(App)

const apollo = createApollo({
  client: apolloClient,
})

app.use(apollo)

app.mount('#app')

@productdevbook
Copy link
Member Author

result new struct

image

used

  <div v-if="loading ">
      {{ loading }}
    </div>
    <div v-else-if="error">
      {{ error }}
    </div>
    <div v-else>
      {{ result?.data.countries }}
    </div>

or

    <div >
      {{ result?.data?.countries }}
    </div>

@productdevbook
Copy link
Member Author

Publish new @huntersofbook/vue-apollo@2.0.0-alpha.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant