Skip to content

Commit

Permalink
dep updates
Browse files Browse the repository at this point in the history
  • Loading branch information
alirizwan committed Nov 18, 2023
1 parent b437e3c commit b3b8aa3
Show file tree
Hide file tree
Showing 5 changed files with 12,332 additions and 1,248 deletions.
80 changes: 12 additions & 68 deletions examples/sequelize-graphql-schema.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { GraphQLSchema } = require('graphql');
const express = require('express');
const graphqlHTTP = require('express-graphql');
const { createHandler } = require('graphql-http/lib/use/express');
const expressPlayground = require('graphql-playground-middleware-express').default;
const { JSONType } = require('graphql-sequelize');

const { generateSchema } = require('../src/index')({
Expand All @@ -14,6 +15,8 @@ const { generateSchema } = require('../src/index')({
},
naming: {
input: 'input',
rootQueries: 'RootQueryType',
rootMutations: 'RootMutationType'
},
findOneQueries: true,
importTypes: {
Expand All @@ -23,70 +26,7 @@ const { generateSchema } = require('../src/index')({
customGlobalType: { id: 'id', key: 'string', value: 'string' },
},
permissions: () => {
return Promise.resolve({
rules: {
mutations: [{
name: 'customGlobalMutation',
enable: true
}],
queries: [{
name: 'customGlobalQuery',
enable: false
}],
fetch: [
{
model: 'Product',
fields: [],
associations: ['Media'],
enable: true,
conditions: [
{ field: 'isActive', value: true }
],
count: false,
findOne: false
},
{
model: 'ProductMedia',
fields: ['imageId']
},
],

/*create: [
{
model: 'Product',
set: {
field: 'isActive', value: true
}
},
{
model: 'ProductMedia',
enable: false
},
],
update: [
{
model: 'Product',
fields: ['name'],
associations: ['Media'],
conditions: [
{ field: 'isActive', value: true }
],
},
],
delete: [
{
model: 'Product',
conditions: [
{ field: 'isActive', value: false }
],
},
{
model: 'ProductMedia',
enable: false
},
],*/
},
});
return Promise.resolve({});
},
queries: {
customGlobalQuery: {
Expand Down Expand Up @@ -127,15 +67,19 @@ const { generateSchema } = require('../src/index')({
const app = express();
const models = require('./models');

app.use('/', async (req, res) => {
app.all('/', async (req, res) => {
const schema = await generateSchema(models, req);

await graphqlHTTP({
const handler = createHandler({
schema: new GraphQLSchema(schema),
graphiql: true,
})(req, res);
});

handler(req, res);
});

app.get('/gql', expressPlayground({ endpoint: '/' }));

app.listen(3000, () => {
// eslint-disable-next-line no-console
console.log('RUNNING ON 3000');
Expand Down
Loading

0 comments on commit b3b8aa3

Please sign in to comment.