From 1fd02c18b7c633574b4420fd47cbbeb5dcf3a839 Mon Sep 17 00:00:00 2001 From: anuveyatsu Date: Fri, 19 Jun 2020 18:12:21 +0600 Subject: [PATCH] [mocks][s]: move graphql schema into separate file and add 'DatasetResponse' type. --- mock/index.js | 52 +--------------------------------------- mock/schema.graphql | 58 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 51 deletions(-) create mode 100644 mock/schema.graphql diff --git a/mock/index.js b/mock/index.js index 08e8cc70..5df96dc3 100644 --- a/mock/index.js +++ b/mock/index.js @@ -2,57 +2,7 @@ const { GraphQLScalarType } = require('graphql'); const { ApolloServer } = require('apollo-server'); const { makeExecutableSchema } = require('graphql-tools'); const { importSchema } = require('graphql-import'); -const typeDefs = ` - type Query { - search(query: SearchQuery!): Response! - } - - input SearchQuery { - q: String! - } - - type Response { - success: Boolean! - result: Result! - } - - type Result { - count: Int! - sort: String! - facets: String! - search_facets: String! - results: [Package!]! - } - - type Package { - name: String! - title: String! - notes: String! - resources: [Resource!]! - organization: Organization! - metadata_created: String! - metadata_modified: String! - } - - type Resource { - name: String! - id: String! - title: String! - format: String! - created: String! - last_modified: String! - datastore_active: Boolean! - url: String! - } - - type Organization { - name: String! - title: String! - description: String! - created: String! - image_url: String! - } -`; +const typeDefs = importSchema('./schema.graphql'); const resolvers = { Query: { diff --git a/mock/schema.graphql b/mock/schema.graphql new file mode 100644 index 00000000..e77c8cb9 --- /dev/null +++ b/mock/schema.graphql @@ -0,0 +1,58 @@ +type Query { + search(query: SearchQuery!): Response! +} + +type Query { + dataset(id: String!): DatasetResponse! +} + +input SearchQuery { + q: String! +} + +type Response { + success: Boolean! + result: Result! +} + +type DatasetResponse { + success: Boolean! + result: Package! +} + +type Result { + count: Int! + sort: String! + facets: String! + search_facets: String! + results: [Package!]! +} + +type Package { + name: String! + title: String! + notes: String! + resources: [Resource!]! + organization: Organization! + metadata_created: String! + metadata_modified: String! +} + +type Resource { + name: String! + id: String! + title: String! + format: String! + created: String! + last_modified: String! + datastore_active: Boolean! + url: String! +} + +type Organization { + name: String! + title: String! + description: String! + created: String! + image_url: String! +}