Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Customer = new GraphQLObjectType({
- description: 'Customer data schema',
- name: 'Customer',
- fields: () => ({
- name: {
- type: GraphQLString,
- sqlColumn: 'NAME',
- },
- city: {
- type: GraphQLString,
- sqlColumn: 'CITY'
- },
- country: {
- type: GraphQLString,
- sqlColumn: 'COUNTRY'
- },
- gender: {
- type: GraphQLString,
- sqlColumn: 'GENDER'
- },
- emp_id: {
- type: GraphQLString,
- sqlColumn: 'EMP_ID'
- }
- })
- });
- Customer._typeConfig = {
- sqlTable: 'CUSTOMER',
- uniqueKey: ['NAME','EMP_ID']
- }
- const QueryRoot = new GraphQLObjectType({
- description: 'global query object',
- name: 'RootQuery',
- fields: () => ({
- customer: {
- type: new GraphQLList(Customer),
- args: {
- emp_id: {
- description: 'Emp Id',
- type: GraphQLString
- },
- name: {
- description: 'Customer Name',
- type: GraphQLString
- }
- },
- where: (customer, args, context) => {
- return `${customer}."EMP_ID" = :emp_id AND ${customer}."NAME" = :name`;
- },
- resolve: (parent, args, context, resolveInfo) => {
- return joinMonster(resolveInfo, context, sql => {
- console.log('joinMaster', sql);
- return database.simpleExecute(sql, args,{
- outFormat: database.OBJECT
- });
- });
- }
- }
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement