Skip to content

Commit 138b5de

Browse files
committed
chore: 🔧 implementing refetchingQueries
1 parent 2df084a commit 138b5de

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

components/PostBox.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Avatar from './Avatar'
66
import { useMutation } from '@apollo/client'
77
import { ADD_POST, ADD_SUBREDDIT } from '../graphql/mutations'
88
import client from '../apollo-client'
9-
import { GET_SUBREDDIT_BY_TOPIC } from '../graphql/queries'
9+
import { GET_ALL_POSTS, GET_SUBREDDIT_BY_TOPIC } from '../graphql/queries'
1010
import toast from 'react-hot-toast'
1111

1212
type FormData = {
@@ -18,7 +18,9 @@ type FormData = {
1818

1919
function PostBox() {
2020
const { data: session } = useSession()
21-
const [addPost] = useMutation(ADD_POST)
21+
const [addPost] = useMutation(ADD_POST, {
22+
refetchQueries: [GET_ALL_POSTS, 'getPostList']
23+
})
2224
const [addSubreddit] = useMutation(ADD_SUBREDDIT)
2325

2426
const [imageBoxOpen, setImageBoxOpen] = useState<boolean>(false)

stepzen/postgresql/postgresql.graphql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ type Query {
7070
@dbquery(
7171
type: "postgresql"
7272
schema: "public"
73-
table: "post"
73+
query: """
74+
select * from "post"
75+
order by "post"."created_at" desc
76+
"""
7477
configuration: "postgresql_config"
7578
)
7679
getPost(id: ID!): Post

0 commit comments

Comments
 (0)