[mocks][s]: move graphql schema into separate file and add 'DatasetResponse' type.

This commit is contained in:
anuveyatsu 2020-06-19 18:12:21 +06:00
parent 8b8adccc74
commit 1fd02c18b7
2 changed files with 59 additions and 51 deletions

View File

@ -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: {

58
mock/schema.graphql Normal file
View File

@ -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!
}