diff --git a/mock/index.js b/mock/index.js index 5df96dc3..429ec2a8 100644 --- a/mock/index.js +++ b/mock/index.js @@ -4,6 +4,66 @@ const { makeExecutableSchema } = require('graphql-tools'); const { importSchema } = require('graphql-import'); const typeDefs = importSchema('./schema.graphql'); +const gdp = { + name: 'gdp', + title: 'Country, Regional and World GDP (Gross Domestic Product)', + notes: + 'Country, regional and world GDP in current US Dollars ($). Regional means collections of countries e.g. Europe & Central Asia. Data is sourced from the World Bank and turned into a standard normalized CSV.', + resources: [ + { + name: 'gdp', + id: 'gdp', + title: 'GDP data', + format: 'csv', + created: '2019-03-07T12:00:36.273495', + last_modified: '2020-05-07T12:00:36.273495', + datastore_active: false, + url: 'http://mock.filestore/gdp.csv', + }, + ], + organization: { + title: 'World Bank', + name: 'world-bank', + description: + 'The World Bank is an international financial institution that provides loans and grants to the governments of poorer countries for the purpose of pursuing capital projects.', + created: '2019-03-07T11:51:13.758844', + image_url: + 'https://github.com/datahq/frontend/raw/master/public/img/avatars/world-bank.jpg', + }, + metadata_created: '2019-03-07T11:56:19.696257', + metadata_modified: '2019-03-07T12:03:58.817280', +}; + +const population = { + name: 'population', + title: 'World population data', + notes: + 'Population figures for countries, regions (e.g. Asia) and the world. Data comes originally from World Bank and has been converted into standard CSV.', + resources: [ + { + name: 'population', + id: 'population', + title: 'Population data', + format: 'csv', + created: '2019-03-07T12:00:36.273495', + last_modified: '2020-05-07T12:00:36.273495', + datastore_active: true, + url: 'http://mock.filestore/population.csv', + }, + ], + organization: { + title: 'World Bank', + name: 'world-bank', + description: + 'The World Bank is an international financial institution that provides loans and grants to the governments of poorer countries for the purpose of pursuing capital projects.', + created: '2019-03-07T11:51:13.758844', + image_url: + 'https://github.com/datahq/frontend/raw/master/public/img/avatars/world-bank.jpg', + }, +}; + +const datapackages = [gdp, population]; + const resolvers = { Query: { search: (parent, { query }) => ({ @@ -12,64 +72,7 @@ const resolvers = { count: 2, sort: 'score desc, metadata_modified desc', facets: {}, - results: [ - { - name: 'gdp', - title: 'Country, Regional and World GDP (Gross Domestic Product)', - notes: - 'Country, regional and world GDP in current US Dollars ($). Regional means collections of countries e.g. Europe & Central Asia. Data is sourced from the World Bank and turned into a standard normalized CSV.', - resources: [ - { - name: 'gdp', - id: 'gdp', - title: 'GDP data', - format: 'csv', - created: '2019-03-07T12:00:36.273495', - last_modified: '2020-05-07T12:00:36.273495', - datastore_active: false, - url: 'http://mock.filestore/gdp.csv', - }, - ], - organization: { - title: 'World Bank', - name: 'world-bank', - description: - 'The World Bank is an international financial institution that provides loans and grants to the governments of poorer countries for the purpose of pursuing capital projects.', - created: '2019-03-07T11:51:13.758844', - image_url: - 'https://github.com/datahq/frontend/raw/master/public/img/avatars/world-bank.jpg', - }, - metadata_created: '2019-03-07T11:56:19.696257', - metadata_modified: '2019-03-07T12:03:58.817280', - }, - { - name: 'population', - title: 'World population data', - notes: - 'Population figures for countries, regions (e.g. Asia) and the world. Data comes originally from World Bank and has been converted into standard CSV.', - resources: [ - { - name: 'population', - id: 'population', - title: 'Population data', - format: 'csv', - created: '2019-03-07T12:00:36.273495', - last_modified: '2020-05-07T12:00:36.273495', - datastore_active: true, - url: 'http://mock.filestore/population.csv', - }, - ], - organization: { - title: 'World Bank', - name: 'world-bank', - description: - 'The World Bank is an international financial institution that provides loans and grants to the governments of poorer countries for the purpose of pursuing capital projects.', - created: '2019-03-07T11:51:13.758844', - image_url: - 'https://github.com/datahq/frontend/raw/master/public/img/avatars/world-bank.jpg', - }, - }, - ], + results: datapackages, search_facets: {}, }, }), @@ -83,17 +86,7 @@ const schema = makeExecutableSchema({ const server = new ApolloServer({ schema, - mocks: { - success: () => { - return new Date(); - }, - result: () => { - return { - firstName: 'Kouki', - lastName: 'Saito', - }; - }, - }, + mocks: true, }); server.listen().then(({ url }) => {