Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
typegenAutoConfig: {
// debug: true,
sources: [{ source: path.join(__dirname, './types.ts'), alias: 'types' }],
contextType: 'types.Context',
},
// backingTypeMap: {
// EmailAddress: 'string',
// DateTime: 'string',
// Max1024Chars: 'string',
// Max140Chars: 'string',
// URL: 'string',
// },
});
const server = new ApolloServer({
schema,
context: async ({ req }: { req: IncomingMessage }): Promise => {
if (req.headers.host == null) throw new Error('missing req.headers.host');
const user = await getUser(API_SECRET, prisma, req);
const models = createModels(prisma, user, req.headers.host);
return { models };
},
// Enable introspection and playground for production.
introspection: true,
playground: true,
});
const { IS_NOW } = process.env;
const handler = withCORS(
ports.api,
import { ApolloServer } from "apollo-server-micro";
import { DownwriteAPI, schema } from "../../utils/graphql";
import { REST_ENDPOINT } from "../../utils/urls";
const server = new ApolloServer({
schema,
async context({ req }) {
const token: string = req.cookies.DW_TOKEN || req.headers.authorization;
return {
authScope,
token
};
},
playground: {
settings: {
"editor.fontFamily": "Operator Mono, monospace"
// "schema.polling.enable": false
}
},
dataSources() {
return {
import { ApolloServer } from "apollo-server-micro";
import { importSchema } from "graphql-import";
import jwt from "jsonwebtoken";
import Mongoose from "mongoose";
import { NextApiRequest, NextApiResponse } from "next";
import { resolvers, IResolverContext } from "../../utils/resolvers";
import { IUser, IPost, PostModel, UserModel } from "../../utils/models";
import { MongoSource } from "../../utils/data-source";
import { prepareDB } from "../../utils/prepare-db";
const typeDefs = importSchema("pages/api/schema.graphql");
let connection: typeof Mongoose;
const server = new ApolloServer({
typeDefs,
resolvers,
async context({ req }) {
const token: string = req.cookies.DW_TOKEN || req.headers.authorization;
const authScope = jwt.decode(token);
connection = await prepareDB();
return {
authScope
};
},
playground: {
settings: {
"editor.fontFamily": "Operator Mono, monospace",
"editor.theme": "light"
// "schema.polling.enable": false
}
const { ApolloServer } = require('apollo-server-micro')
const db = require('@firstmeanseverything/db')
const { makeExecutableSchema } = require('graphql-tools')
const { applyMiddleware } = require('graphql-middleware')
const resolvers = require('./resolvers')
const loaders = require('./loaders')
const permissions = require('./permissions')
const typeDefs = require('./typeDefs')
const { getUserId, withCors } = require('./utils')
const server = new ApolloServer({
schema: applyMiddleware(
makeExecutableSchema({
typeDefs,
resolvers,
inheritResolversFromInterfaces: true
}),
permissions
),
context: async req => ({
...req,
db,
loaders,
userId: await getUserId({ ...req })
}),
introspection: true,
playground: true
const resolvers = {
Query: {
subreddit: async (_: any, { name }) => {
const response: SubredditData = await fetch(
`https://www.reddit.com/r/${name}.json`,
).then(r => r.json());
return response && response.data;
},
},
Subreddit: {
posts: (subreddit: Subreddit) =>
subreddit ? subreddit.children.map(child => child.data) : [],
},
};
const server = new ApolloServer({
typeDefs,
resolvers,
introspection: true,
playground: true,
});
export const config = {
api: {
bodyParser: false,
},
};
export default server.createHandler({ path: '/api/graphql' });
photo_1.typeDefs,
post_1.typeDefs,
todo_1.typeDefs,
user_1.typeDefs,
];
var resolvers = {
Query: __assign({}, album_1.resolvers.Query, comment_1.resolvers.Query, page_1.resolvers.Query, photo_1.resolvers.Query, post_1.resolvers.Query, todo_1.resolvers.Query, user_1.resolvers.Query),
Mutation: __assign({}, album_1.resolvers.Mutation, comment_1.resolvers.Mutation, page_1.resolvers.Mutation, photo_1.resolvers.Mutation, post_1.resolvers.Mutation, todo_1.resolvers.Mutation, user_1.resolvers.Mutation),
Album: album_1.resolvers.Album,
Comment: comment_1.resolvers.Comment,
Photo: photo_1.resolvers.Photo,
Post: post_1.resolvers.Post,
Todo: todo_1.resolvers.Todo,
User: user_1.resolvers.User,
};
return new apollo_server_micro_1.ApolloServer({
typeDefs: typeDefs,
resolvers: resolvers,
introspection: true,
playground: {
settings: {
'editor.theme': 'light',
}
}
});
}
exports.buildApolloServer = buildApolloServer;
id: ID! @unique
hash: String! @unique
message: String
files: [File]!
}
type File {
id: ID! @unique
createdAt: DateTime!
name: String!
}
`;
const schema = makeExecutableSchema(sdl, memdown());
const apolloServer = new ApolloServer({ schema, tracing: true });
module.exports = apolloServer.createHandler();
module.exports = function createHandler(options) {
let Raven
if (options.ravenDsn) {
Raven = require('raven')
Raven.config(options.ravenDsn, {
release: options.version,
environment: process.env.NODE_ENV,
}).install()
}
const formatError = createErrorFormatter(Raven)
const apolloServer = new ApolloServer({ schema, formatError })
return apolloServer.createHandler({ path: '/' })
}