How to use the apollo-server-express.makeExecutableSchema function in apollo-server-express

To help you get started, we’ve selected a few apollo-server-express examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github terascope / teraslice / packages / data-access-plugin / src / dynamic-server / index.ts View on Github external
// tslint:disable-next-line
            const { schema, ...serverObj } = this;

            /**
             * This is the main reason to extend, to access graphqlExpress(),
             * to be able to modify the schema based on the request
             * It binds to our new object, since the parent accesses the schema
             * from this.schema etc.
             */
            return graphqlExpress(
                // @ts-ignore
                super.createGraphQLServerOptions.bind({
                    ...serverObj,
                    graphqlPath: path,
                    /* Retrieves a custom graphql schema based on request */
                    schema: makeExecutableSchema({
                        typeDefs,
                        resolvers,
                        inheritResolversFromInterfaces: true,
                    }),
                    formatError: utils.formatError,
                    playground: {
                        settings: {
                            'request.credentials': 'include',
                        }
                    } as apollo.PlaygroundConfig
                })
            )(req, res, next);
        });
    }
github frandiox / vue-graphql-enterprise-boilerplate / server / src / apollo-server.js View on Github external
context = () => ({}),
    // Subscriptions
    subscriptionsEndpoint = '',
    wsMiddlewares = [],
    // Mocks
    mocks,
    // Apollo Engine
    engineKey = '',
    // HTTP options
    cors = true,
    timeout = 120000,
    // Extra options for Apollo Server
    apolloServerOptions = {},
  }
) {
  const schema = makeExecutableSchema({
    typeDefs,
    resolvers,
    schemaDirectives,
    directiveResolvers,
    resolverValidationOptions: {
      requireResolversForResolveType: false,
    },
  })

  // Apollo server options
  const options = {
    ...apolloServerOptions,
    schema: applyGraphQLMiddleware(schema, ...graphqlMiddlewares),
    tracing: true,
    cacheControl: true,
    engine: engineKey ? { apiKey: engineKey } : false,
github Thorium-Sim / thorium / server / bootstrap / apollo.ts View on Github external
import {
  ApolloServer,
  makeExecutableSchema,
  ApolloServerExpressConfig,
} from "apollo-server-express";
import vanity from "./vanity";
import http from "http";
import ipAddress from "../helpers/ipaddress";
import {typeDefs, resolvers} from "../data";
import chalk from "chalk";
// Load some other stuff
import "../events";
import "../processes";
export const schema = makeExecutableSchema({
  typeDefs,
  resolvers,
  resolverValidationOptions: {
    requireResolversForResolveType: false,
  },
});

// TODO: Change app to the express type
export default (app: any, SERVER_PORT: number) => {
  const graphqlOptions: ApolloServerExpressConfig = {
    schema,
    engine: {
      apiKey: "service:Thorium:yZHa-qq7-_kVSpmsc9Ka1A",
    },
    tracing: process.env.NODE_ENV !== "production",
    introspection: true,
github qmit-pro / moleculer-api / src / schema / plugin / protocol / graphql / handler / handlers.ts View on Github external
constructor(onMessage: (message: string | Error) => void, opts: GraphQLHandlersOptions) {
    const {typeDefs, resolvers, schemaDirectives, parseOptions, subscriptions, uploads, playground, ...restOptions} = opts;
    const schema = makeExecutableSchema({
      typeDefs: typeDefs || [],
      resolvers,
      logger: {
        log: onMessage,
      },
      allowUndefinedInResolve: false,
      resolverValidationOptions: {
        requireResolversForArgs: true,
        requireResolversForNonScalar: false,
        // requireResolversForAllFields: false,
        requireResolversForResolveType: false, // rather use InterfaceImplementationType.__isTypeOf than InterfaceType.__resolveType for distributed schema
        allowResolversNotInSchema: false,
      },
      schemaDirectives,
      parseOptions,
      inheritResolversFromInterfaces: false,
github nestjs / graphql / lib / graphql-definitions.factory.ts View on Github external
private async exploreAndEmit(
    typePaths: string[],
    path: string,
    outputAs: 'class' | 'interface',
    isDebugEnabled: boolean,
  ) {
    const typeDefs = await this.gqlTypesLoader.mergeTypesByPaths(
      typePaths || [],
    );
    if (!typeDefs) {
      throw new Error(`"typeDefs" property cannot be null.`);
    }
    let schema = makeExecutableSchema({
      typeDefs,
      resolverValidationOptions: { allowResolversNotInSchema: true },
    });
    schema = removeTempField(schema);
    const tsFile = this.gqlAstExplorer.explore(
      gql`
        ${printSchema(schema)}
      `,
      path,
      outputAs,
    );
    await tsFile.save();
    this.printMessage(
      `[${new Date().toLocaleTimeString()}] The definitions have been updated.`,
      isDebugEnabled,
    );
github kamilkisiela / graphql-inspector / packages / api / src / schema.ts View on Github external
import {baseSchema} from './base-schema';
import {makeExecutableSchema} from 'apollo-server-express';
import {mergeGraphQLSchemas} from '@graphql-modules/epoxy';
import * as common from './modules/common';
import * as coverage from './modules/coverage';
import * as diff from './modules/diff';
import * as validate from './modules/validate';
import * as similar from './modules/similar';

export const schema = makeExecutableSchema({
  typeDefs: mergeGraphQLSchemas([
    baseSchema,
    common.typeDefs,
    coverage.typeDefs,
    diff.typeDefs,
    validate.typeDefs,
    similar.typeDefs,
  ]),
  resolvers: [
    coverage.resolvers,
    diff.resolvers,
    validate.resolvers,
    similar.resolvers,
  ] as any,
});
github nestjs / graphql / lib / graphql.factory.ts View on Github external
): Promise {
    const resolvers = this.resolversExplorerService.explore();
    const typesResolvers = extend(
      this.scalarsExplorerService.explore(),
      resolvers,
    );
    const transformSchema = async (schema: GraphQLSchema) =>
      options.transformSchema ? await options.transformSchema(schema) : schema;

    if (options.autoSchemaFile) {
      const autoGeneratedSchema: GraphQLSchema = await this.gqlSchemaBuilder.build(
        options.autoSchemaFile,
        options.buildSchemaOptions,
        this.resolversExplorerService.getAllCtors(),
      );
      const executableSchema = makeExecutableSchema({
        resolvers: extend(typesResolvers, options.resolvers),
        typeDefs: gql`
          ${printSchema(autoGeneratedSchema)}
        `,
        resolverValidationOptions: {
          ...(options.resolverValidationOptions || {}),
          requireResolversForResolveType: false,
        },
      });
      let schema = options.schema
        ? mergeSchemas({
            schemas: [options.schema, executableSchema],
          })
        : executableSchema;

      const autoGeneratedSchemaConfig = autoGeneratedSchema.toConfig();
github hmmChase / next-graphql-starter / backend / src / schema / index.js View on Github external
import { makeExecutableSchema } from 'apollo-server-express';
import { importSchema } from 'graphql-import';
import resolvers from '../resolvers';

const typeDefs = importSchema(__dirname + '/schema.graphql');

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

export default schema;
github wslyvh / buidl-explorer / server / graphql / schemas / issue.schema.ts View on Github external
import { addMockFunctionsToSchema, gql, makeExecutableSchema } from "apollo-server-express";
import { GraphQLSchema } from "graphql";

const issueSchema: GraphQLSchema = makeExecutableSchema({ typeDefs: gql`
	type Query {
		issues: [Issue]
	}

	type Issue {
		id: String!
		number: String!
		title: String!
		bodyText: String!
		state: String!
		url: String!
		author: Author
		labels: Labels!
		repository: Repository
		createdAt: String!
		updatedAt: String!