1

I'm trying to add my/custom/path/to the $path variable but have no idea on how to do this. Already looked at the documentation but couldn't find anything that mentions this.

export const postQuery = graphql`
    query BlogPostByPath($path: String!) {
        markdownRemark(frontmatter: { path: { eq: $path } }) {
            html
            frontmatter {
                path
                title
                description
                keywords
            }
        }
    }
`;
2
  • Can you show the resolve function of markdownRemark? First time seeing such nested argument passing. Are you using Apollo as GraphQl client? Commented May 6, 2018 at 14:51
  • @ArupRakshit I'm using gatsby and the plugin called gatsby-transformer-remark so it might look different. I'm not sure what else I can provide to help you :/ Commented May 6, 2018 at 14:54

1 Answer 1

3

If you are using Gatsby, try:

graphql(`<your_query_with_variable>`, { variable: <value_of_variable> })

Source: Passing a string to GraphQL queries argument.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.