You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to reuse my fragment definition and query with variable in many types of page. how can i implement this.
for example:
exportconstarticleNodeFields=graphql` fragment articleNodeFields on mongodbDatabaseArticles { id title source summary content info { author top_img } }`exportconstquerySourcedArticle=graphql`query querySourcedArticle($source: String) { allMongodbDatabaseArticles( limit: 10 filter: { info: { top_img: { ne: null } }, summary: { ne: null }, source: {eq: $source} } sort: { fields: id, order: DESC } ) { edges { node { ...articleNodeFields // HOW to use fragment here? } } }}`andatpage```jsimport {querySourcedArticle} from "file-from-above"export const pageQuery = graphql`querySourcedArticle(source: "topic1")// HOW
`
## Relevant information
<!-- Provide as much useful information as you can -->
### Environment (if relevant)
<!--
Required. Run `gatsby info --clipboard` in your gatsby project directory and paste its contents here.
Not working? You may need to update your global gatsby-cli - `npm install -g gatsby-cli`
-->
### File contents (if changed)
`gatsby-config.js`: N/A <!-- Please use a code block or just leave it as is if wasn't changed -->
`package.json`: N/A <!-- Please use a code block or just leave it as is if wasn't changed -->
`gatsby-node.js`: N/A <!-- Please use a code block or just leave it as is if wasn't changed -->
`gatsby-browser.js`: N/A <!-- Please use a code block or just leave it as is if wasn't changed -->
`gatsby-ssr.js`: N/A <!-- Please use a code block or just leave it as is if wasn't changed -->
The text was updated successfully, but these errors were encountered:
@kakadiadarpan found how to reuse fragment. but i don't find any example for reusing query with variable(like function with parameters). newbie to gatsby's graphql
@sivagao currently, parameterized fragments are not supported by GraphQL. You can follow the original issue on GraphQL repo here - graphql/graphql-spec#204
Summary
I want to reuse my fragment definition and query with variable in many types of page. how can i implement this.
for example:
The text was updated successfully, but these errors were encountered: