adamsoffer / adamsoffer/next-apollo

Is it possible to switch getInitialProps to getServerSideProps?

Abierto
#95 3 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
477
Forks
62
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Well, since this withApollo hoc is using getInitialProps for ssr, there is a conflict when using getServerSideProps on a page component.

```

const Restaurant: NextPage = ({ id }) => {
console.log("id", id);
const { data, loading } = useRestaurantQuery({
variables: {
input: {
restaurantId: id,
},
},
});

console.log("loading", loading);
console.log("data", data);
if (loading) {
return

Loading...
;
}

return (


restaurant
{data?.restaurant.result?.name}


);
};

export default withApollo({ssr: true})(Restaurant);

export const getServerSideProps: GetServerSideProps = async (ctx) => {
console.log("ctx", ctx);

const { id } = ctx.query;
if (!id) {
return {
props: {},
};
}

return {
props: { id: parseInt(id as string) },
};
};
```

![Screen Shot 2021-01-28 at 12 38 45 PM](https://user-images.githubusercontent.com/28520573/106086581-c59e2900-6165-11eb-8782-94efb53154d6.png)

So, I'm looking for a way to make withApollo hoc utlizing getServerSideProps for "ssr" mode.

Could there be a way to do that?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.