folders.forEach(folder => {
     const { resolvers } = require(`../modules/${folder}/resolvers`);
     const typeDefs = importSchema(
       path.join(__dirname, `../modules/${folder}/schema.graphql`)
     );
 
     // Make a schema for each folder in module and store the schema for each folder
     // in the schema array
     schemas.push(
       makeExecutableSchema({ resolvers, typeDefs })
     );
   })
Example #2
0
export function readSchema(path): GraphQLSchema {
  // FIXME: prefix error
  switch (extname(path)) {
    case '.graphql':
      return valueToSchema(importSchema(path))
    case '.json':
      const data = readFileSync(path, { encoding: 'utf-8' })
      const introspection = JSON.parse(data)
      return valueToSchema(introspection)
    default:
      throw new Error(
        'Unsupported schema file extention. Only ".graphql" and ".json" are supported',
      )
  }
}
Example #3
0
import { processRequest } from 'apollo-upload-server';
import * as graphqlHTTP from 'express-graphql';
import { graphql, printSchema } from 'graphql';
import { importSchema } from 'graphql-import';
import { makeExecutableSchema } from 'graphql-tools';
import { SampleService } from '../services';

const dirname = process.env.LAMBDA_TASK_ROOT ? `${process.env.LAMBDA_TASK_ROOT}/app/graphql` : __dirname;

export const schema = makeExecutableSchema({
  typeDefs: importSchema(`${dirname}/index.graphql`),
  resolvers: [
    SampleService.resolvers,
  ],
});

const middleware = graphqlHTTP((request, response?, graphQLParams?) => {
  if (graphQLParams) {
    request.body = {
      query: graphQLParams.query && graphQLParams.query.replace(/\s+/g, ' '),
      variables: graphQLParams.variables,
      operationName: graphQLParams.operationName,
    };
  }
  return {
    schema,
    graphiql: process.env.NODE_ENV !== 'production',
    extensions: ({ result }) => {
      (response as any).errors = result.errors;
      return {};
    },
Example #4
0
          id
          file
        }
        previousValues {
          id
          file
        }
      }`
        );
      }
    }
  }
};
//console.log(db.subscription.organization)
const firstSchema = importSchema(
  path.join(__dirname, "./generated/prisma.graphql")
);
const secondSchema = importSchema(path.join(__dirname, "./schema.graphql"));
const schema = makeExecutableSchema({ typeDefs: firstSchema });
//addMockFunctionsToSchema({ schema });
const schema2 = makeExecutableSchema({ typeDefs: secondSchema });
//addMockFunctionsToSchema({ schema:schema2 });

//const schemas = [firstSchema, secondSchema];

export const ultimateSchema = mergeSchemas({
  schemas: [schema, schema2],
  resolvers
});
//console.log(ultimateSchema.getSubscriptionType().getFields())
import { makeExecutableSchema } from 'graphql-tools';
import { nodeInterface, pageInfoType } from 'graphql-relay-tools';
import { importSchema } from 'graphql-import';

import resolvers from './resolvers';

import { swapiDef } from './schema/swapi';

const schemas = {
  nodeInterface,
  pageInfoType,
  ...swapiDef,
};

const typeDefs: string = importSchema('src/graphql/schema/schema.graphql', schemas);

const schema = makeExecutableSchema({
  typeDefs,
  resolvers,
});

export default schema;