Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ cache:
notifications:
email: true
node_js:
- '10'
- '8'
- "12"
- "10"
- "8"
script:
- yarn run test
- yarn run build
after_success:
- 'curl -Lo travis_after_all.py https://git.io/travis_after_all'
- "curl -Lo travis_after_all.py https://git.io/travis_after_all"
- python travis_after_all.py
- export $(cat .to_export_back) &> /dev/null
- if [[ "$TRAVIS_JOB_NUMBER" == *.1 && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then bash <(curl -s https://codecov.io/bash); fi
Expand Down
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"javascript.validate.enable": false,
"editor.formatOnSave": true,
"eslint.validate": [
{ "language": "javascript", "autoFix": true },
{ "language": "javascriptreact", "autoFix": true }
]
"eslint.validate": ["javascript", "javascriptreact"]
}
19 changes: 15 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"node8"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/relay-tools/react-relay-network-modern-ssr.git"
Expand Down Expand Up @@ -38,6 +39,7 @@
"@babel/plugin-proposal-object-rest-spread": "^7.4.4",
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@types/graphql": "14.2.3",
"babel-eslint": "^10.0.2",
"babel-jest": "^24.8.0",
"babel-plugin-replace-imports": "^1.0.2",
Expand All @@ -58,7 +60,12 @@
"react-relay-network-modern": "^4.0.1",
"relay-runtime": "^5.0.0",
"rimraf": "^2.6.3",
"semantic-release": "^15.13.16"
"semantic-release": "^15.13.16",
"tslint": "^6.0.0",
"tslint-config": "^0.0.1",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.1.0",
"typescript": "^3.8.3"
},
"config": {
"commitizen": {
Expand All @@ -72,10 +79,14 @@
},
"scripts": {
"build": "npm run build-lib && npm run build-node8",
"build-lib": "rimraf lib && BABEL_ENV=lib babel src --ignore __tests__,__mocks__ -d lib && BABEL_ENV=lib_server babel src/server.js -d lib && COPY_TO_FOLDER=lib npm run build-flow",
"build-node8": "rimraf node8 && BABEL_ENV=node8 babel src --ignore __tests__,__mocks__ -d node8 && COPY_TO_FOLDER=node8 npm run build-flow",
"build-lib": "rimraf lib && BABEL_ENV=lib babel src --ignore __tests__,__mocks__ -d lib && BABEL_ENV=lib_server babel src/server.js -d lib && COPY_TO_FOLDER=lib npm run build-flow && COPY_TO_FOLDER=lib npm run build-dts",
"build-node8": "rimraf node8 && BABEL_ENV=node8 babel src --ignore __tests__,__mocks__ -d node8 && COPY_TO_FOLDER=node8 npm run build-flow && COPY_TO_FOLDER=node8 npm run build-dts",
"build-flow": "echo `$1` && find ./src -name '*.js' -not -path '*/__*' | while read filepath; do cp $filepath `echo ./${COPY_TO_FOLDER:-lib}$filepath | sed 's/.\\/src\\//\\//g'`.flow; done",
"lint": "eslint 'src/**/*.js'",
"build-dts": "echo `$1` && find ./src -name '*d.ts' -not -path '*/__*' | while read filepath; do cp $filepath `echo ./${COPY_TO_FOLDER:-lib}$filepath | sed 's/.\\/src\\//\\//g'`; done",
"lint": "npm run eslint && npm run tslint && npm run tscheck",
"eslint": "eslint --ext .js ./src",
"tslint": "tslint -p . \"src/**/*.d.ts\"",
"tscheck": "tsc --noEmit",
"coverage": "jest --coverage --maxWorkers 2",
"watch": "jest --watch",
"flow": "flow",
Expand Down
19 changes: 19 additions & 0 deletions src/client.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MiddlewareSync, QueryPayload } from "react-relay-network-modern";
import { SSRCache } from "./server";

type RelayClientSSRMiddlewareOpts = {
lookup?: boolean;
};

export default class RelayClientSSR {
cache?: Map<string, QueryPayload>;
debug: boolean;

constructor(cache?: SSRCache);

getMiddleware(opts?: RelayClientSSRMiddlewareOpts): MiddlewareSync;

clear(): void;

log(...args: any[]): void;
}
Empty file added src/index.d.ts
Empty file.
27 changes: 27 additions & 0 deletions src/server.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Middleware, QueryPayload } from "react-relay-network-modern";
import { GraphQLSchema, GraphQLFieldResolver, ExecutionResult } from "graphql";

type SSRGraphQLArgs = {
schema: GraphQLSchema;
rootValue?: unknown;
contextValue?: unknown;
operationsName?: string;
fieldResolver?: GraphQLFieldResolver<any, any>;
};

export type SSRCache = ([string, QueryPayload])[];

export default class RelayServerSSR {
cache: Map<string, Promise<ExecutionResult>>;
debug: boolean;

constructor();

getMiddleware(
args?: SSRGraphQLArgs | (() => Promise<SSRGraphQLArgs>)
): Middleware;

getCache(): Promise<SSRCache>;

log(...args: any[]): void;
}
7 changes: 7 additions & 0 deletions src/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type ValueType = string | object | ValueType[];

export function isFunction(obj: unknown): obj is object;

export function stableCopy(value: ValueType): ValueType;

export function getCacheKey(queryID: string, variables: object): string;
12 changes: 12 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"lib": ["es2017", "esnext.asynciterable", "dom"],
"noImplicitAny": false,
"noEmit": true
},
"include": ["src/**/*.d.ts", "src/**/*.spec.ts"],
"exclude": ["./node_modules"]
}
34 changes: 34 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"defaultSeverity": "error",
"extends": ["tslint:recommended", "tslint-config-prettier"],
"rulesDirectory": ["tslint-plugin-prettier"],
"jsRules": {},
"rules": {
"prettier": [true],
"trailing-comma": [false],
"ordered-imports": false,
"max-classes-per-file": false,
"member-access": false,
"ban-types": {
"options": [
["Object", "Avoid using the `Object` type. Did you mean `object`?"],
["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"],
["Number", "Avoid using the `Number` type. Did you mean `number`?"],
["String", "Avoid using the `String` type. Did you mean `string`?"],
["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"]
]
},
"member-ordering": [
true,
{
"order": "fields-first"
}
],
"variable-name": false,
"arrow-parens": false,
"interface-name": false,
"no-reference-import": false,
"interface-over-type-literal": false,
"object-literal-sort-keys": false
}
}
Loading