Answer the question
In order to leave comments, you need to log in
How to pass parameter to graphql file?
I started to study graphql and ran into this problem:
How to properly import a graphql file into react.js and how to pass a variable to the imported file
code:
query GetAllProjects{
getAllProjects{
id,
title,
slug,
content
}
getProjectInfo{
id,
title,
slug,
content
}
}
import * as GetAllProjects from '../graphql/project.graphql';
Answer the question
In order to leave comments, you need to log in
Like this:
query GetAllProjects($param: TypeParam, $param2: TypeParam2){
getAllProjects{
id,
title,
slug,
content
}
getProjectInfo(param: $param, param2: $param2){
id,
title,
slug,
content
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question