Resolve merge conflicts

This commit is contained in:
Elliot DeNolf
2019-04-27 11:51:23 -04:00
14 changed files with 141 additions and 18 deletions

View 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
View 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
}
`;

View File

@@ -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
View 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;

View 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
View 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 });

View File

@@ -1,5 +1,5 @@
require('@babel/register')({
ignore: [ /(node_modules)/ ]
ignore: [/(node_modules)/]
});
require('./app');

View File

@@ -44,5 +44,9 @@
"width": 16,
"height": 16
}
]
],
"graphQL": {
"path": "/graphql",
"graphiql": true
}
}