mirror of
https://github.com/aleleba/create-node-ts-graphql-server.git
synced 2025-07-18 18:48:24 -06:00
PR-780243: Adding strict to types.
This commit is contained in:
package-lock.jsonpackage.json
src
tsconfig.json@ -6,17 +6,17 @@ import { getTest, addText } from '@controllerGraphQL';
|
||||
const resolvers = {
|
||||
Query: {
|
||||
// eslint-disable-next-line
|
||||
test: (rootValue, args, context) => ({}),
|
||||
test: (rootValue: any, args: any, context: any) => ({}),
|
||||
},
|
||||
Mutation: {
|
||||
// eslint-disable-next-line
|
||||
testMutation: (rootValue, args, context) => ({}),
|
||||
testMutation: (rootValue: any, args: any, context: any) => ({}),
|
||||
},
|
||||
Test: {
|
||||
test: (rootValue, args, context) => getTest({rootValue, args, context})
|
||||
test: (rootValue: any, args: any, context: any) => getTest({rootValue, args, context})
|
||||
},
|
||||
TestMutation: {
|
||||
testMutation: (rootValue, args, context) => addText({rootValue, args, context})
|
||||
testMutation: (rootValue: any, args: any, context: any) => addText({rootValue, args, context})
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { makeExecutableSchema } from '@graphql-tools/schema';
|
||||
import resolvers from'@GraphQL/resolvers';
|
||||
import Test from './Test.gql';
|
||||
import Test from '@GraphQL/schema/Test.gql';
|
||||
|
||||
// The GraphQL schema
|
||||
const rootTypes = `
|
||||
|
@ -21,8 +21,9 @@ server.use(
|
||||
|
||||
// DO NOT DO app.listen() unless we're testing this directly
|
||||
if (require.main === module) {
|
||||
server.listen((process.env.PORT || 4000), () => {
|
||||
console.log(`Iniciando Express en el puerto 4000${server.graphqlPath}`); /*${app.get('port')}*/
|
||||
const app = express();
|
||||
app.listen((process.env.PORT || 4000), () => {
|
||||
console.log(`Iniciando Express en el puerto 4000`); /*${app.get('port')}*/
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,16 @@
|
||||
import { getTestModel, addTextModel } from '@models';
|
||||
|
||||
// eslint-disable-next-line
|
||||
export const getTest = async ({rootValue, args, context}) => {
|
||||
export const getTest = async ({}) => {
|
||||
return getTestModel();
|
||||
};
|
||||
|
||||
// eslint-disable-next-line
|
||||
export const addText = async ({rootValue, args, context}) => {
|
||||
export const addText = async ({args}: {
|
||||
rootValue: any
|
||||
args: { text: string }
|
||||
context: any
|
||||
}) => {
|
||||
const text = args.text;
|
||||
return addTextModel({ text });
|
||||
};
|
@ -15,8 +15,8 @@ import apiRouter from '@routes';
|
||||
const app = express(), //creating app
|
||||
whitelist = config.WHITELIST_URLS,
|
||||
corsOptions = {
|
||||
origin: function (origin, callback) {
|
||||
if (whitelist.indexOf(origin) !== -1 || !origin) {
|
||||
origin: function (origin: string | undefined, callback: (arg0: Error | null, arg1?: boolean) => void) {
|
||||
if (whitelist.indexOf(origin as string) !== -1 || !origin) {
|
||||
callback(null, true);
|
||||
} else {
|
||||
callback(new Error('Not allowed by CORS'));
|
||||
@ -29,7 +29,7 @@ const app = express(), //creating app
|
||||
app
|
||||
.use(cookieParser())
|
||||
.use(express.urlencoded({limit: '500mb', extended: true}))
|
||||
.use(express.json({limit: '500mb', extended: true}))
|
||||
.use(express.json({limit: '500mb'}))
|
||||
.use(cors(corsOptions))
|
||||
.use(apiRouter)//Routes de App
|
||||
.use('/graphql', GraphQLserver);//Server of Graphql
|
||||
|
@ -4,6 +4,6 @@ export const getTestModel = async () => {
|
||||
return 'This is the text response for Test Query from a model';
|
||||
};
|
||||
|
||||
export const addTextModel = async ({ text }) => {
|
||||
export const addTextModel = async ({ text }: {text: string}) => {
|
||||
return `Simulate to insert some text: ${text} from a model`;
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
import server from '@src';
|
||||
import supertest from 'supertest';
|
||||
describe('global server tests', () => {
|
||||
let request;
|
||||
let request: supertest.SuperTest<supertest.Test>;
|
||||
beforeEach(() => {
|
||||
request = supertest(server);
|
||||
});
|
||||
|
Reference in New Issue
Block a user