I am trying to use fragments to reuse my graphql code but its not working although before using fragment code works fine.
This is how my code looks like
fragments.js
import gql from 'graphql-tag';
export const postFragment = gql`
fragment PostData on postsConnection {
edges {
node {
id
title
date
featuredImage {
sourceUrl
}
}
}
} `
this is my query file queries/posts.js
import gql from 'graphql-tag';
import {postFragment} from '../fragments';
export const getAllPosts = gql`
query getAllPosts {
posts {
...PostData
}
}
${postFragment}
`;
This is the error get
[GraphQL error]: Message: Unknown type "postsConnection"., Location: [object Object], Path: undefined
How can i fix this?