@graphql-ts/schema
is a thin wrapper around
GraphQL.js providing type-safety for
constructing GraphQL Schemas while avoiding type-generation, declaration merging
and decorators.
import { graphql } from "@graphql-ts/schema";
import { GraphQLSchema, graphql as runGraphQL } from "graphql";
const Query = graphql.object()({
name: "Query",
fields: {
hello: graphql.field({
type: graphql.String,
resolve() {
return "Hello!";
},
}),
},
});
const schema = new GraphQLSchema({
query: Query.graphQLType,
});
runGraphQL({
source: `
query {
hello
}
`,
schema,
}).then((result) => {
console.log(result);
});