Skip to content

KunalSin9h/load-gql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

load-gql

A tiny GraphQL schema loader

Usage

Add dependency

npm i @kunalsin9h/load-gql

Usage

import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
import loadGraphQL from "@kunalsin9h/load-gql";
import resolvers from "./resolvers";

// assuming graphql-schemas is a folder where all the schema files reside
const typeDefs = loadGraphQL("graphql-schemas", "temp.gql");

const server = new ApolloServer({
  typeDefs,
  resolvers,
});

const { url } = await startStandaloneServer(server, {
  listen: {
    port: 3033,
  },
});

console.log(`Started server at ${url}`);