mirror of
https://github.com/FranP-code/countries.git
synced 2025-10-13 00:02:15 +00:00
added field countries for continents
This commit is contained in:
10
index.js
10
index.js
@@ -1,5 +1,5 @@
|
||||
import resolvers from './resolvers';
|
||||
import typeDefs from './schema';
|
||||
import resolvers from './resolvers.js';
|
||||
import typeDefs from './schema.js';
|
||||
import {ApolloServer} from 'apollo-server';
|
||||
import {continents, countries, languages} from 'countries-list';
|
||||
|
||||
@@ -15,14 +15,14 @@ const server = new ApolloServer({
|
||||
resolvers,
|
||||
introspection: true,
|
||||
playground: true,
|
||||
engine: {
|
||||
apiKey: process.env.ENGINE_API_KEY
|
||||
},
|
||||
context: {
|
||||
continents: Object.entries(continents).map(([code, name]) => ({
|
||||
code,
|
||||
name
|
||||
})),
|
||||
engine: {
|
||||
apiKey: process.env.ENGINE_API_KEY
|
||||
},
|
||||
countries: toArray(countries),
|
||||
languages: toArray(languages)
|
||||
}
|
||||
|
||||
28
package-lock.json
generated
28
package-lock.json
generated
@@ -3227,12 +3227,14 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@@ -3247,17 +3249,20 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@@ -3374,7 +3379,8 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@@ -3386,6 +3392,7 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@@ -3400,6 +3407,7 @@
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@@ -3407,12 +3415,14 @@
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.2.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"yallist": "^3.0.0"
|
||||
@@ -3431,6 +3441,7 @@
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@@ -3511,7 +3522,8 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@@ -3523,6 +3535,7 @@
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@@ -3644,6 +3657,7 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
||||
@@ -9,6 +9,10 @@ export default {
|
||||
languages: (country, args, {languages}) =>
|
||||
languages.filter(language => country.languages.includes(language.code))
|
||||
},
|
||||
Continent: {
|
||||
countries: (continent, args, {countries}) =>
|
||||
countries.filter(country => country.continent === continent.code)
|
||||
},
|
||||
Query: {
|
||||
continent: (parent, args, {continents}) =>
|
||||
continents.find(byCode(args.code)),
|
||||
|
||||
Reference in New Issue
Block a user