including CAIT data, models and seeds
This commit is contained in:
30
routes/query.graphql
Normal file
30
routes/query.graphql
Normal file
@@ -0,0 +1,30 @@
|
||||
query GetAllCountries {
|
||||
countries {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
query GetYearData {
|
||||
data(year: $years, country_id: $country_ids){
|
||||
...DatumFragment
|
||||
}
|
||||
}
|
||||
query GetCountryData($id: Integer!) {
|
||||
countries(id: $id){
|
||||
data {
|
||||
...DatumFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment DatumFragment on Datum {
|
||||
year
|
||||
population
|
||||
gdp
|
||||
total_emissions
|
||||
energy_emissions
|
||||
industrial_emissions
|
||||
agriculture_emissions
|
||||
waste_emissions
|
||||
lucf_emissions
|
||||
}
|
||||
37
routes/shema.js
Normal file
37
routes/shema.js
Normal file
@@ -0,0 +1,37 @@
|
||||
var queryType = new GraphQLObjectType({
|
||||
name: 'Query',
|
||||
fields: () => ({
|
||||
countries: {
|
||||
type: new GraphQLList(Country.graphql),
|
||||
args: {
|
||||
id: {
|
||||
type: new GraphQLNonNull(GraphQLInteger)
|
||||
},
|
||||
name: {
|
||||
type: new GraphQLNonNull(GraphQLString)
|
||||
}
|
||||
},
|
||||
resolve: (root, args) => {
|
||||
Country.sql.find(args)
|
||||
}
|
||||
},
|
||||
data: {
|
||||
type: new GraphQLList(Datum.graphql),
|
||||
args: {
|
||||
years: {
|
||||
type: new GraphQLList(GraphQLInteger)
|
||||
},
|
||||
country_id: {
|
||||
type: new GraphQLList(GraphQLInteger)
|
||||
}
|
||||
},
|
||||
resolve: (root, args)=>{
|
||||
Datum.findAll({where: args})
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
module.exports = new GraphQLSchema({
|
||||
query: queryType
|
||||
});
|
||||
Reference in New Issue
Block a user