Error: BabelPluginRemoveGraphQL: String interpolations
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am getting below error when trying to pass variable dynamically in gatsBy Graphql.
Error
Module build failed (from ./node_modules/gatsby/dist/utils/babel-loader.js):
Error: BabelPluginRemoveGraphQL: String interpolations are not allowed in graphql fragments. Included fragments should be referenced as `...MyModule_foo`.
Query
let mytext = 'welcome'
let myQuery = graphql`query($text: String = "${mytext}") {
allGhostPost : allGhostPost(filter:{title:{eq: $text}}) {
edges {
node {
id
slug
}
}
}
}`
Please help!!!
graphql gatsby
add a comment |
I am getting below error when trying to pass variable dynamically in gatsBy Graphql.
Error
Module build failed (from ./node_modules/gatsby/dist/utils/babel-loader.js):
Error: BabelPluginRemoveGraphQL: String interpolations are not allowed in graphql fragments. Included fragments should be referenced as `...MyModule_foo`.
Query
let mytext = 'welcome'
let myQuery = graphql`query($text: String = "${mytext}") {
allGhostPost : allGhostPost(filter:{title:{eq: $text}}) {
edges {
node {
id
slug
}
}
}
}`
Please help!!!
graphql gatsby
add a comment |
I am getting below error when trying to pass variable dynamically in gatsBy Graphql.
Error
Module build failed (from ./node_modules/gatsby/dist/utils/babel-loader.js):
Error: BabelPluginRemoveGraphQL: String interpolations are not allowed in graphql fragments. Included fragments should be referenced as `...MyModule_foo`.
Query
let mytext = 'welcome'
let myQuery = graphql`query($text: String = "${mytext}") {
allGhostPost : allGhostPost(filter:{title:{eq: $text}}) {
edges {
node {
id
slug
}
}
}
}`
Please help!!!
graphql gatsby
I am getting below error when trying to pass variable dynamically in gatsBy Graphql.
Error
Module build failed (from ./node_modules/gatsby/dist/utils/babel-loader.js):
Error: BabelPluginRemoveGraphQL: String interpolations are not allowed in graphql fragments. Included fragments should be referenced as `...MyModule_foo`.
Query
let mytext = 'welcome'
let myQuery = graphql`query($text: String = "${mytext}") {
allGhostPost : allGhostPost(filter:{title:{eq: $text}}) {
edges {
node {
id
slug
}
}
}
}`
Please help!!!
graphql gatsby
graphql gatsby
asked Nov 16 '18 at 13:59
Dark KnightDark Knight
119116
119116
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Inserting arbitrary text into queries like this is a well-known security issue and the Babel plugin is almost certainly right to forbid it. GraphQL defines a JSON-over-HTTP payload format that allows passing the variables separately (encoded as JSON objects to minimize the possibility of injection attacks).
You don't show what's actually making the query, but it should have a place to add a map of GraphQL variables. (For example, the graphql-js reference implementation includes a variableValues
parameter to its top-level graphql
function.) Remove the = "${mytext}"
part of the query, and instead use a variables object like {text: mytext}
.
1
Thank you but what is the solution? I need to pass dynamicallymytext
.
– Dark Knight
Nov 19 '18 at 10:40
this suggests that you can not pass a variable to the string as the query is resolved at compile time.
– User
Feb 25 at 22:02
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339309%2ferror-babelpluginremovegraphql-string-interpolations%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Inserting arbitrary text into queries like this is a well-known security issue and the Babel plugin is almost certainly right to forbid it. GraphQL defines a JSON-over-HTTP payload format that allows passing the variables separately (encoded as JSON objects to minimize the possibility of injection attacks).
You don't show what's actually making the query, but it should have a place to add a map of GraphQL variables. (For example, the graphql-js reference implementation includes a variableValues
parameter to its top-level graphql
function.) Remove the = "${mytext}"
part of the query, and instead use a variables object like {text: mytext}
.
1
Thank you but what is the solution? I need to pass dynamicallymytext
.
– Dark Knight
Nov 19 '18 at 10:40
this suggests that you can not pass a variable to the string as the query is resolved at compile time.
– User
Feb 25 at 22:02
add a comment |
Inserting arbitrary text into queries like this is a well-known security issue and the Babel plugin is almost certainly right to forbid it. GraphQL defines a JSON-over-HTTP payload format that allows passing the variables separately (encoded as JSON objects to minimize the possibility of injection attacks).
You don't show what's actually making the query, but it should have a place to add a map of GraphQL variables. (For example, the graphql-js reference implementation includes a variableValues
parameter to its top-level graphql
function.) Remove the = "${mytext}"
part of the query, and instead use a variables object like {text: mytext}
.
1
Thank you but what is the solution? I need to pass dynamicallymytext
.
– Dark Knight
Nov 19 '18 at 10:40
this suggests that you can not pass a variable to the string as the query is resolved at compile time.
– User
Feb 25 at 22:02
add a comment |
Inserting arbitrary text into queries like this is a well-known security issue and the Babel plugin is almost certainly right to forbid it. GraphQL defines a JSON-over-HTTP payload format that allows passing the variables separately (encoded as JSON objects to minimize the possibility of injection attacks).
You don't show what's actually making the query, but it should have a place to add a map of GraphQL variables. (For example, the graphql-js reference implementation includes a variableValues
parameter to its top-level graphql
function.) Remove the = "${mytext}"
part of the query, and instead use a variables object like {text: mytext}
.
Inserting arbitrary text into queries like this is a well-known security issue and the Babel plugin is almost certainly right to forbid it. GraphQL defines a JSON-over-HTTP payload format that allows passing the variables separately (encoded as JSON objects to minimize the possibility of injection attacks).
You don't show what's actually making the query, but it should have a place to add a map of GraphQL variables. (For example, the graphql-js reference implementation includes a variableValues
parameter to its top-level graphql
function.) Remove the = "${mytext}"
part of the query, and instead use a variables object like {text: mytext}
.
answered Nov 16 '18 at 19:48
David MazeDavid Maze
15.9k31532
15.9k31532
1
Thank you but what is the solution? I need to pass dynamicallymytext
.
– Dark Knight
Nov 19 '18 at 10:40
this suggests that you can not pass a variable to the string as the query is resolved at compile time.
– User
Feb 25 at 22:02
add a comment |
1
Thank you but what is the solution? I need to pass dynamicallymytext
.
– Dark Knight
Nov 19 '18 at 10:40
this suggests that you can not pass a variable to the string as the query is resolved at compile time.
– User
Feb 25 at 22:02
1
1
Thank you but what is the solution? I need to pass dynamically
mytext
.– Dark Knight
Nov 19 '18 at 10:40
Thank you but what is the solution? I need to pass dynamically
mytext
.– Dark Knight
Nov 19 '18 at 10:40
this suggests that you can not pass a variable to the string as the query is resolved at compile time.
– User
Feb 25 at 22:02
this suggests that you can not pass a variable to the string as the query is resolved at compile time.
– User
Feb 25 at 22:02
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339309%2ferror-babelpluginremovegraphql-string-interpolations%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown