2017-05-28 4 views
2

モジュールが見つからないファイルを生成しません解決できません './ を生成 /GetAllCities.graphql'リレーコンパイラは.graphql

コンポーネント:リレーコンパイラコマンド

export class Map extends React.Component { 
21 constructor(props){ 
22  super(props); 
23 }; 


24 render(){ 
25  return(
26  <div id='map'> 
27  <GoogleMapReact 
28  bootstrapURLKeys={{key: ''}} 
29  defaultCenter={this.props.center} 
30  defaultZoom={this.props.zoom} 
31  > 
32   <QueryRenderer 
33   environment={environment} 
34   query={graphql` 
35    query GetAllCities { 
36    cities { 
37     id 
38     lat 
39    } 
40    } 
41   `} 
42   render={ 
43    ({error, props}) => { 
44    if (error) { 
45     return <div>{error.message}</div>; 
46    } else if (props) { 
47     console.log(props); 
48     return <div>{props.data.id}</div>; 
49    } 
50     return <div>Loading</div>; 
51    } 
52   } 
53   /> 
54  </GoogleMapReact> 

11  "relay": "relay-compiler --src ./src --schema ./data/schema.graphql --extensions=js,jsx", 

スキーマ:

1 # A city to be used on the map 
    2 type City { 
    3 id: Int! 
    4 lat: Float 
    5 lng: Float 
    6 todo: [ToDo] 
    7 } 
    8 
    9 # Mutations for the To Do List 
10 type Mutation { 
11 createToDo(city_id: Int!, text: String!): ToDo 
12 } 
13 
14 # An array of Cities 
15 type Query { 
16 cities: [City] 
17 city(id: Int): City 
18 } 
19 
20 # A To Do for a city 
21 type ToDo { 
22 city_id: Int! 
23 text: String 
24 likes: Int 
25 id: Int! 
26 } 

babelrcファイル:

1 { 
    2 "plugins": [ 
    3  ["relay", { 
    4  "compat": true, 
    5  "schema": "./data/schema.graphql", 
    6  "enforceSchema": true, 
    7  "suppressWarnings": false, 
    8  "debug": false, 
    9  }] 
10 ], 
11 "presets": ["react", "es2015", "es2016", "es2017"] 
12 }~ 

主要な問題は、糸の実行リレーまたはNPMの実行リレーでは、生成 GetAllCities.graphql

を生成しません。また、何のエラーを取得していません。以前はフラグメントコンテナで動作していました。ファイル名を.jsに変更しても機能しません。

答えて

2

を見るん:

"relay": "relay-compiler --src ./src --schema ./data/schema.graphql --extensions=js --extensions=jsx" 
3

答えはにpackages.confスクリプトを変更しました:

"リレー": "リレー・コンパイラ--src ./src --schema ./data/schema.graphql --extensions JSX"

それは今だけJSXファイル上で動作しますが、それはそうのように二回あなたが旗を提供する必要があり、両方の拡張子を取得するには、彼らに