Getting Stuck with Apollo
See original GitHub issueDear @brillout,
Thank you for this plugin, it looks very promising.
update: seems to be working perfectly now!
If you have time, would you mind creating a very basic example using apollo client? I am probably doing something stupid but I don’t think I can figure it out on my own.
// apollo/index.ts
import 'cross-fetch/polyfill';
import { ApolloClient } from '@apollo/client'
import { InvalidationPolicyCache } from 'apollo-invalidation-policies';
export const client = new ApolloClient({
cache: new InvalidationPolicyCache({}),
uri: 'https://countries.trevorblades.com'
})
// pages/tests/index.page.server.ts
import { gql } from '@apollo/client'
import {client} from '../../apollo'
export { addContextProps }
export { setPageProps }
export const LIST_COUNTRIES = gql`
{
countries {
name
code
}
}
`;
async function addContextProps({ contextProps }) {
const response = await client.query({query: LIST_COUNTRIES})
return { countries: response.data.countries }
}
function setPageProps({ contextProps: { countries } }) {
return { countries }
}
// pages/tests/index.page.tsx
import React from "react";
import { useQuery } from '@apollo/client'
import "./index.css";
import {client} from '../../apollo'
import {LIST_COUNTRIES} from './index.page.server'
export { Page };
function Page({countries}) {
const {data} = useQuery(LIST_COUNTRIES, {client});
console.log('countries', countries) // This is not working
console.log('data', data) // This works
return (
<>
<h1>TEsts</h1>
<p>A okay text.</p>
</>
);
}
Thank you very much,
Lydia
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Headphone Tip Stuck in Apollo - Gearspace.com
Little bit of a situation, a dodgy headphone adaptor has broken off inside the headphone output of my Apollo Quad (normal one, not...
Read more >A P O L L O - Wait (Stuck with Me) - YouTube
A P O L L O - Wait ( Stuck with Me) Video created by Music Waves Media Subscribe for more videos This...
Read more >Cables stuck in Twin | UAD, Apollo, and LUNA Forums
I have two 1/4 line cables in the combo jack of my Apollo Twin. For some reason they don't want to come out....
Read more >Apollo sometimes gets stuck loading content : r/apolloapp
I am experiencing the same issue several times a day. To work around this I force quit the app and restart it.
Read more >What If We Got Stuck on the Moon? - Literary Hub
Apollo 11 astronauts Neil Armstrong and Buzz Aldrin deliberately refused to contemplate what might happen if the Eagle's ascent engine failed on ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @felixakiragreen, I deleted the last comment mistakenly if you read it, if you didnt: no good news from me. We couldn’t fix it in the end and I had spent ages refactoring so I didn’t get the circ dep warnings, but it still didn’t work. I can’t remember what exact the issue was but we figured it was probably the ssr circular dep issue in the vite repo and we decided, with heavy hearts, to let ssr go until it was fixed!
https://github.com/vitejs/vite/issues/2258
Make sure to use
await
:Otherwise
pageHtml
won’t get set.Also you should initialize the Apollo client only once at startup time, instead of initializing it on every HTTP request.