本文整理汇总了TypeScript中graphql-import.importSchema函数的典型用法代码示例。如果您正苦于以下问题:TypeScript importSchema函数的具体用法?TypeScript importSchema怎么用?TypeScript importSchema使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了importSchema函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: require
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 })
);
})
示例2: readSchema
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',
)
}
}
示例3: makeExecutableSchema
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 {};
},
示例4: importSchema
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())
示例5: importSchema
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;