Skip to content

Commit

Permalink
πŸŽ‰ initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
blutarche committed Mar 6, 2020
0 parents commit fe484ac
Show file tree
Hide file tree
Showing 15 changed files with 2,827 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PORT=4000
22 changes: 22 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"env": {
"node": true,
"amd": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
yarn-error.log
.env
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"singleQuote": true,
"no-func-assign": false,
"proseWrap": "always"
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TypeScript GraphQL Starter πŸš€

Get Started Real Fast!
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "typescript-graphql-starter",
"version": "1.0.0",
"main": "src/index.ts",
"repository": "[email protected]:blutarche/typescript-graphql-starter.git",
"author": "Aikdanai Sidhikosol <[email protected]>",
"license": "MIT",
"private": true,
"scripts": {
"dev": "ts-node-dev --no-notify --respawn --transpileOnly -r dotenv/config ./src/index"
},
"dependencies": {
"apollo-server": "2.10.1",
"graphql": "14.6.0",
"graphql-iso-date": "3.6.1",
"graphql-type-json": "0.3.1",
"lodash": "4.17.15",
"nexus": "0.12.0-rc.13"
},
"devDependencies": {
"@types/lodash": "4.14.149",
"@types/node": "13.7.6",
"@typescript-eslint/eslint-plugin": "2.21.0",
"@typescript-eslint/parser": "2.21.0",
"dotenv": "8.2.0",
"eslint": "6.8.0",
"ts-node-dev": "1.0.0-pre.44",
"typescript": "3.8.2"
}
}
104 changes: 104 additions & 0 deletions src/generated/generated-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/**
* This file was automatically generated by GraphQL Nexus
* Do not make changes to this file directly
*/


import { core } from "nexus"
declare global {
interface NexusGenCustomInputMethods<TypeName extends string> {
date<FieldName extends string>(fieldName: FieldName, opts?: core.ScalarInputFieldConfig<core.GetGen3<"inputTypes", TypeName, FieldName>>): void // "DateTime";
jsonObject<FieldName extends string>(fieldName: FieldName, opts?: core.ScalarInputFieldConfig<core.GetGen3<"inputTypes", TypeName, FieldName>>): void // "JSONObject";
json<FieldName extends string>(fieldName: FieldName, opts?: core.ScalarInputFieldConfig<core.GetGen3<"inputTypes", TypeName, FieldName>>): void // "JSON";
}
}
declare global {
interface NexusGenCustomOutputMethods<TypeName extends string> {
date<FieldName extends string>(fieldName: FieldName, ...opts: core.ScalarOutSpread<TypeName, FieldName>): void // "DateTime";
jsonObject<FieldName extends string>(fieldName: FieldName, ...opts: core.ScalarOutSpread<TypeName, FieldName>): void // "JSONObject";
json<FieldName extends string>(fieldName: FieldName, ...opts: core.ScalarOutSpread<TypeName, FieldName>): void // "JSON";
}
}


declare global {
interface NexusGen extends NexusGenTypes {}
}

export interface NexusGenInputs {
}

export interface NexusGenEnums {
}

export interface NexusGenRootTypes {
Query: {};
String: string;
Int: number;
Float: number;
Boolean: boolean;
ID: string;
DateTime: any;
JSON: any;
JSONObject: any;
}

export interface NexusGenAllTypes extends NexusGenRootTypes {
}

export interface NexusGenFieldTypes {
Query: { // field return type
ok: boolean; // Boolean!
}
}

export interface NexusGenArgTypes {
}

export interface NexusGenAbstractResolveReturnTypes {
}

export interface NexusGenInheritedFields {}

export type NexusGenObjectNames = "Query";

export type NexusGenInputNames = never;

export type NexusGenEnumNames = never;

export type NexusGenInterfaceNames = never;

export type NexusGenScalarNames = "Boolean" | "DateTime" | "Float" | "ID" | "Int" | "JSON" | "JSONObject" | "String";

export type NexusGenUnionNames = never;

export interface NexusGenTypes {
context: any;
inputTypes: NexusGenInputs;
rootTypes: NexusGenRootTypes;
argTypes: NexusGenArgTypes;
fieldTypes: NexusGenFieldTypes;
allTypes: NexusGenAllTypes;
inheritedFields: NexusGenInheritedFields;
objectNames: NexusGenObjectNames;
inputNames: NexusGenInputNames;
enumNames: NexusGenEnumNames;
interfaceNames: NexusGenInterfaceNames;
scalarNames: NexusGenScalarNames;
unionNames: NexusGenUnionNames;
allInputTypes: NexusGenTypes['inputNames'] | NexusGenTypes['enumNames'] | NexusGenTypes['scalarNames'];
allOutputTypes: NexusGenTypes['objectNames'] | NexusGenTypes['enumNames'] | NexusGenTypes['unionNames'] | NexusGenTypes['interfaceNames'] | NexusGenTypes['scalarNames'];
allNamedTypes: NexusGenTypes['allInputTypes'] | NexusGenTypes['allOutputTypes']
abstractTypes: NexusGenTypes['interfaceNames'] | NexusGenTypes['unionNames'];
abstractResolveReturn: NexusGenAbstractResolveReturnTypes;
}


declare global {
interface NexusGenPluginTypeConfig<TypeName extends string> {
}
interface NexusGenPluginFieldConfig<TypeName extends string, FieldName extends string> {
}
interface NexusGenPluginSchemaConfig {
}
}
24 changes: 24 additions & 0 deletions src/generated/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
### This file was autogenerated by GraphQL Nexus
### Do not make changes to this file directly


"""
A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the
`date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO
8601 standard for representation of dates and times using the Gregorian calendar.
"""
scalar DateTime

"""
The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
"""
scalar JSON

"""
The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
"""
scalar JSONObject

type Query {
ok: Boolean!
}
1 change: 1 addition & 0 deletions src/graphql/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './scalar'
7 changes: 7 additions & 0 deletions src/graphql/scalar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { asNexusMethod } from 'nexus'
import { GraphQLDateTime } from 'graphql-iso-date'
import GraphQLJSON, { GraphQLJSONObject } from 'graphql-type-json'

export const DateScalar = asNexusMethod(GraphQLDateTime, 'date')
export const JSONObjectScalar = asNexusMethod(GraphQLJSONObject, 'jsonObject')
export const JSONScalar = asNexusMethod(GraphQLJSON, 'json')
20 changes: 20 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ApolloServer } from 'apollo-server'

import { schema } from './schema'

export const apolloConfig = {
schema,
playground: true,
introspection: true,
context: ({ req }) => {
return {
headers: req.headers
}
}
}

const server = new ApolloServer(apolloConfig)
const port = process.env.PORT || 4000
server.listen({ port }).then(({ url }) => {
console.log(`πŸš€ Server ready at ${url}`)
})
15 changes: 15 additions & 0 deletions src/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { makeSchema } from 'nexus'
import path from 'path'
import * as graphQLTypes from './graphql'

export const schema = makeSchema({
types: graphQLTypes,
outputs: {
schema: path.join(__dirname, './generated/schema.graphql'),
typegen: path.join(__dirname, './generated/generated-types.d.ts')
},
nonNullDefaults: {
input: false,
output: false
}
})
3 changes: 3 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface Context {
providerId: string
}
18 changes: 18 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es2019",
"noImplicitAny": false,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": "src",
"paths": {
"*": ["node_modules/*", "src/@types/*"]
},
"types": ["node"]
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}
Loading

0 comments on commit fe484ac

Please sign in to comment.