[refactor][m]: implement efficient gql management system (#41)
This commit is contained in:
@@ -1,23 +1,9 @@
|
||||
import { GetServerSideProps } from 'next';
|
||||
import { initializeApollo } from '../../../lib/apolloClient';
|
||||
import Head from 'next/head';
|
||||
import { initializeApollo } from '../../../lib/apolloClient';
|
||||
import Nav from '../../../components/home/Nav';
|
||||
import Post from '../../../components/static/Post';
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
const QUERY = gql`
|
||||
query post($slug: String) {
|
||||
post(slug: $slug)
|
||||
@rest(type: "Post", path: "{args.slug}", endpoint: "wordpress") {
|
||||
title
|
||||
content
|
||||
excerpt
|
||||
slug
|
||||
date
|
||||
modified
|
||||
}
|
||||
}
|
||||
`;
|
||||
import { GET_POST_QUERY } from '../../../graphql/queries';
|
||||
|
||||
function PostItem({ variables }) {
|
||||
return (
|
||||
@@ -42,7 +28,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||
const apolloClient = initializeApollo();
|
||||
|
||||
await apolloClient.query({
|
||||
query: QUERY,
|
||||
query: GET_POST_QUERY,
|
||||
variables,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user