Resolve merge conflicts
This commit is contained in:
21
demo/Page/Page.resolvers.js
Normal file
21
demo/Page/Page.resolvers.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import Page from './Page.model';
|
||||
import { modelById } from '../../src/resolvers';
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
page: async (parent, args) => {
|
||||
|
||||
const query = {
|
||||
Model: Page,
|
||||
id: args.id,
|
||||
locale: args.locale,
|
||||
fallback: args['fallbackLocale']
|
||||
}
|
||||
|
||||
return await modelById(query);
|
||||
},
|
||||
pages: async (parent, args) => {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
20
demo/Page/Page.types.js
Normal file
20
demo/Page/Page.types.js
Normal file
@@ -0,0 +1,20 @@
|
||||
export default `
|
||||
type Page {
|
||||
id: String
|
||||
title: String
|
||||
content: String
|
||||
metaTitle: String
|
||||
metaDesc: String
|
||||
createdAt: String
|
||||
updatedAt: String
|
||||
}
|
||||
|
||||
type Query {
|
||||
page(id: String!, locale: String): Page
|
||||
pages: [Page]
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
addPage(title: String, content: String): Page
|
||||
}
|
||||
`;
|
||||
@@ -1,11 +1,12 @@
|
||||
import express from 'express';
|
||||
import payload from '../src';
|
||||
|
||||
import User from './User/User.model';
|
||||
import payloadConfig from './payload.config';
|
||||
|
||||
import { authRoutes } from './Auth/Auth.routes';
|
||||
import { userRoutes } from './User/User.routes';
|
||||
import { pageRoutes } from './Page/Page.routes';
|
||||
import schema from '../demo/graphql';
|
||||
|
||||
const router = express.Router({}); // eslint-disable-line new-cap
|
||||
|
||||
@@ -16,6 +17,7 @@ payload.init({
|
||||
app: app,
|
||||
user: User,
|
||||
router: router,
|
||||
graphQLSchema: schema,
|
||||
cors: ['http://localhost:8080', 'http://localhost:8081']
|
||||
});
|
||||
|
||||
|
||||
7
demo/graphql/index.js
Normal file
7
demo/graphql/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { makeExecutableSchema } from 'graphql-tools';
|
||||
import typeDefs from './types';
|
||||
import resolvers from './resolvers';
|
||||
|
||||
const schema = makeExecutableSchema({ typeDefs, resolvers });
|
||||
|
||||
export default schema;
|
||||
7
demo/graphql/resolvers.js
Normal file
7
demo/graphql/resolvers.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { mergeResolvers } from 'merge-graphql-schemas';
|
||||
|
||||
import Page from '../Page/Page.resolvers';
|
||||
|
||||
const resolvers = [Page];
|
||||
|
||||
export default mergeResolvers(resolvers);
|
||||
7
demo/graphql/types.js
Normal file
7
demo/graphql/types.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { mergeTypes } from 'merge-graphql-schemas';
|
||||
|
||||
import Page from '../Page/Page.types';
|
||||
|
||||
const types = [Page];
|
||||
|
||||
export default mergeTypes(types, { all: true });
|
||||
@@ -1,5 +1,5 @@
|
||||
require('@babel/register')({
|
||||
ignore: [ /(node_modules)/ ]
|
||||
ignore: [/(node_modules)/]
|
||||
});
|
||||
|
||||
require('./app');
|
||||
|
||||
@@ -44,5 +44,9 @@
|
||||
"width": 16,
|
||||
"height": 16
|
||||
}
|
||||
]
|
||||
],
|
||||
"graphQL": {
|
||||
"path": "/graphql",
|
||||
"graphiql": true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user