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;
}







1















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!!!










share|improve this question





























    1















    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!!!










    share|improve this question

























      1












      1








      1








      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!!!










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 13:59









      Dark KnightDark Knight

      119116




      119116
























          1 Answer
          1






          active

          oldest

          votes


















          1














          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}.






          share|improve this answer



















          • 1





            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












          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          1














          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}.






          share|improve this answer



















          • 1





            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
















          1














          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}.






          share|improve this answer



















          • 1





            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














          1












          1








          1







          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}.






          share|improve this answer













          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}.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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 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














          • 1





            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








          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




















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine