[{"data":1,"prerenderedAt":120},["ShallowReactive",2],{"legacy-question-40e2cd9757f1db75d18e5331e1ec852d":3,"legacy-question-author-koji-kadoma":94,"legacy-question-category-website-building":109},{"id":4,"title":5,"author":6,"body":7,"category":80,"date":81,"description":82,"extension":83,"locale":84,"meta":85,"navigation":86,"path":87,"seo":88,"slug":89,"stem":90,"tag":91,"updated":81,"__hash__":93},"legacyQuestions\u002F20210401000000-GridsomeのGraphQLで受け取る変数は？.md","GridsomeのGraphQLで受け取る変数は？","koji-kadoma",{"type":8,"value":9,"toc":75},"minimark",[10,14,18,29,32,35,45,48,51,54,57,63,66,72],[11,12,13],"h2",{"id":13},"page-queryが受け取れる変数は実質二つ",[15,16,17],"p",{},"Gridsomeが自動生成するGraphQLに収容されるクエリには、",[19,20,25],"pre",{"className":21,"code":23,"language":24},[22],"language-text","id: ID\npath: String\nnullable: Boolean = false\n","text",[26,27,23],"code",{"__ignoreMap":28},"",[15,30,31],{},"の3つが、引数として指定されます。",[15,33,34],{},"一方で、Gridsomeのジェネレータ側では、templateとpageでpage-queryを使えますが、",[36,37,38,42],"ol",{},[39,40,41],"li",{},"id: ID",[39,43,44],{},"path: String",[15,46,47],{},"この二つしかページのパラメータから引数として収納していません。つまり、実質「idとpathでしか検索できない」と思って良いでしょう。",[11,49,50],{"id":50},"受け取る変数を使ってクエリを発行する",[15,52,53],{},"この二つで引くようにGraphQLのクエリを発行してみます。",[15,55,56],{},"例えば、このクエリと、",[19,58,61],{"className":59,"code":60,"language":24},[22],"\u003Cpage-query>\n  query Blog($path: String) {\n    articles(path: $path) {\n      title\n      date\n    }\n  }\n\u003C\u002Fpage-query>\n",[26,62,60],{"__ignoreMap":28},[15,64,65],{},"このクエリは、",[19,67,70],{"className":68,"code":69,"language":24},[22],"\u003Cpage-query>\n  query Blog($id: ID) {\n    articles(id: $id) {\n      title\n      date\n    }\n  }\n\u003C\u002Fpage-query>\n",[26,71,69],{"__ignoreMap":28},[15,73,74],{},"基本的には同じ結果を返すはずです。",{"title":28,"searchDepth":76,"depth":76,"links":77},2,[78,79],{"id":13,"depth":76,"text":13},{"id":50,"depth":76,"text":50},"website-building","2021-04-01T00:00:00.000Z","Gridsomeでサイトを作成する","md","ja",{},true,"\u002F20210401000000-gridsomegraphql",{"title":5,"description":82},"40e2cd9757f1db75d18e5331e1ec852d","20210401000000-GridsomeのGraphQLで受け取る変数は？",[92],"gridsome","G06TKQqTdI3sk6_mLtEv0k_U1r-Drt9clag5E7aY_i0",{"id":95,"title":96,"body":97,"date":81,"description":101,"extension":83,"locale":84,"meta":102,"name":105,"navigation":86,"path":106,"seo":107,"slug":6,"stem":6,"updated":81,"__hash__":108},"legacyAuthors\u002Fkoji-kadoma.md","Koji Kadoma",{"type":8,"value":98,"toc":99},[],{"title":28,"searchDepth":76,"depth":76,"links":100},[],"Webエンジニアです。Javascript、PHP、Ruby、Dockerなどをメインで使っています。",{"image":103,"url":104},"https:\u002F\u002Fwww.codit.work\u002Fimgs\u002Favatar\u002Fkoji-kadoma.png","https:\u002F\u002Fkoji.pages.dev\u002F",null,"\u002Fkoji-kadoma",{"title":96,"description":101},"H1yaGicrsv1CzYTbFeEXQosuYx93lIutD3_XwXMhAFk",{"id":110,"title":111,"body":112,"date":81,"description":111,"extension":83,"locale":84,"meta":116,"navigation":86,"path":117,"seo":118,"slug":80,"stem":80,"updated":81,"__hash__":119},"legacyCategories\u002Fwebsite-building.md","Webサイト構築",{"type":8,"value":113,"toc":114},[],{"title":28,"searchDepth":76,"depth":76,"links":115},[],{},"\u002Fwebsite-building",{"title":111,"description":111},"h9jPLD2mzMm3L4sFN5qWSiSirySQQLdnxLhQcvw8VlQ",1783320301848]