mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
added mock tenant api
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { Db } from 'mongodb';
|
||||
|
||||
export interface ContextOptions {
|
||||
db: Db;
|
||||
}
|
||||
|
||||
export default class TenantContext {
|
||||
public db: Db;
|
||||
|
||||
constructor({ db }: ContextOptions) {
|
||||
this.db = db;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { graphqlExpress } from 'apollo-server-express';
|
||||
import schema from './schema';
|
||||
import Context from './context';
|
||||
import { Db } from 'mongodb';
|
||||
|
||||
export default (db: Db) =>
|
||||
graphqlExpress(async req => {
|
||||
return {
|
||||
schema,
|
||||
context: new Context({ db }),
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { addMockFunctionsToSchema } from 'graphql-tools';
|
||||
import { getGraphQLProjectConfig } from 'graphql-config';
|
||||
|
||||
// Load the configuration from the provided `.graphqlconfig` file.
|
||||
const config = getGraphQLProjectConfig(__dirname, 'management');
|
||||
|
||||
// Get the GraphQLSchema from the configuration.
|
||||
const schema = config.getSchema();
|
||||
|
||||
// Attach resolvers to the schema.
|
||||
addMockFunctionsToSchema({
|
||||
schema,
|
||||
mocks: {
|
||||
Cursor: () => new Date().toISOString(),
|
||||
},
|
||||
}); // FIXME: remove mocks
|
||||
|
||||
export default schema;
|
||||
@@ -0,0 +1,39 @@
|
||||
################################################################################
|
||||
## Custom Scalar Types
|
||||
################################################################################
|
||||
|
||||
"""
|
||||
Time represented as an ISO8601 string.
|
||||
"""
|
||||
scalar Time
|
||||
|
||||
"""
|
||||
Cursor represents a paginating cursor.
|
||||
"""
|
||||
scalar Cursor
|
||||
|
||||
################################################################################
|
||||
## Tenant
|
||||
################################################################################
|
||||
|
||||
type Tenant {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
organizationName is the name of the organization.
|
||||
"""
|
||||
organizationName: String
|
||||
|
||||
"""
|
||||
organizationContactEmail is the email of the organization.
|
||||
"""
|
||||
organizationContactEmail: String
|
||||
}
|
||||
|
||||
################################################################################
|
||||
## Query
|
||||
################################################################################
|
||||
|
||||
type Query {
|
||||
tenant(id: ID!): Tenant
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import Asset from './asset';
|
||||
import Comment from './comment';
|
||||
import Cursor from './cursor';
|
||||
import Cursor from '../../common/scalars/cursor';
|
||||
import Query from './query';
|
||||
|
||||
export default {
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
addMockFunctionsToSchema,
|
||||
addResolveFunctionsToSchema,
|
||||
} from 'graphql-tools';
|
||||
import resolvers from 'talk-server/graph/tenant/resolvers';
|
||||
import resolvers from '../resolvers';
|
||||
import { getGraphQLProjectConfig } from 'graphql-config';
|
||||
|
||||
// Load the configuration from the provided `.graphqlconfig` file.
|
||||
@@ -14,12 +14,4 @@ const schema = config.getSchema();
|
||||
// Attach the resolvers to the schema.
|
||||
addResolveFunctionsToSchema({ schema, resolvers });
|
||||
|
||||
// // Attach resolvers to the schema.
|
||||
// addMockFunctionsToSchema({
|
||||
// schema,
|
||||
// mocks: {
|
||||
// Cursor: () => new Date().toISOString(),
|
||||
// },
|
||||
// }); // FIXME: remove mocks
|
||||
|
||||
export default schema;
|
||||
|
||||
Reference in New Issue
Block a user