Skip to content
Open
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
5 changes: 0 additions & 5 deletions .babelrc

This file was deleted.

5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "all"
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
12 changes: 9 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
module.exports = {
verbose: true,
testURL: 'https://foo.bar',
}
verbose: true,
testURL: 'https://foo.bar',
roots: ['<rootDir>/src'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
};
104 changes: 42 additions & 62 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,44 @@
{
"name": "graphql-faunadb",
"version": "0.1.0-rc.9",
"description": "A collection of types and functions to pair GraphQL with FaunaDB",
"license": "MIT",
"main": "index",
"homepage": "https://github.com/shiftx/graphql-faunadb",
"bugs": {
"url": "https://github.com/shiftx/graphql-faunadb/issues"
},
"repository": {
"type": "git",
"url": "http://github.com/shiftx/graphql-faunadb.git"
},
"keywords": [
"graphql",
"faunadb",
"fauna"
],
"engines": {
"node": ">= 6.x"
},
"scripts": {
"test": "jest",
"build": "npm run build:clean && npm run build:cp && npm run build:package-json && npm run build:cjs && npm run build:mjs",
"build:clean": "rm -rf ./dist && mkdir ./dist",
"build:cp": "cp README.md LICENSE ./dist",
"build:package-json": "node ./scripts/copy-package-json.js",
"build:cjs": "babel src --ignore 'src/__fixtures__,**/__tests__' --out-dir dist/",
"build:mjs": "BABEL_MODULES=1 babel src --ignore 'src/__fixtures__,**/__tests__' --out-dir dist/module/ && for file in $(find dist/module -name '*.js'); do mv \"$file\" `echo \"$file\" | sed 's/dist\\/module/dist/g; s/.js$/.mjs/g'`; done && rm -rf dist/module"
},
"dependencies": {
"iterall": "^1.2.2"
},
"peerDependencies": {
"fauandb": "^2.0.0",
"graphql-js": "^0.12.0 ^0.13.0 ^14.0.0"
},
"devDependencies": {
"@babel/cli": "7.1.2",
"@babel/core": "7.1.2",
"@babel/plugin-proposal-class-properties": "7.1.0",
"@babel/plugin-proposal-object-rest-spread": "7.0.0",
"@babel/plugin-syntax-async-generators": "7.0.0",
"@babel/plugin-transform-classes": "7.1.0",
"@babel/plugin-transform-destructuring": "7.1.3",
"@babel/plugin-transform-flow-strip-types": "7.0.0",
"@babel/plugin-transform-spread": "7.0.0",
"@babel/polyfill": "7.0.0",
"@babel/preset-env": "7.1.0",
"@babel/register": "7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"babel-jest": "^23.6.0",
"eslint": "5.6.1",
"eslint-plugin-flowtype": "2.50.3",
"eslint-plugin-prettier": "3.0.0",
"faunadb": "^2.5.2",
"flow-bin": "0.83.0",
"graphql": "^14.0.2",
"jest": "23.6.0",
"prettier": "1.14.3"
}
"name": "graphql-faunadb",
"version": "0.1.0-rc.9",
"description": "A collection of types and functions to pair GraphQL with FaunaDB",
"license": "MIT",
"main": "dist/index.js",
"homepage": "https://github.com/shiftx/graphql-faunadb",
"bugs": {
"url": "https://github.com/shiftx/graphql-faunadb/issues"
},
"repository": {
"type": "git",
"url": "http://github.com/shiftx/graphql-faunadb.git"
},
"keywords": [
"graphql",
"faunadb",
"fauna"
],
"engines": {
"node": ">= 6.x"
},
"scripts": {
"test": "jest",
"build": "tsc",
"format": "prettier src/**/*.ts --write"
},
"dependencies": {},
"peerDependencies": {
"fauandb": "^2.0.0",
"graphql": "^0.12.0 ^0.13.0 ^14.0.0"
},
"devDependencies": {
"@types/graphql": "^14.0.5",
"@types/jest": "^23.3.12",
"@types/node": "^10.12.18",
"faunadb": "^2.5.2",
"graphql": "^14.1.1",
"jest": "23.6.0",
"prettier": "1.14.3",
"ts-jest": "^23.10.5",
"typescript": "^3.2.4"
}
}
16 changes: 0 additions & 16 deletions scripts/copy-package-json.js

This file was deleted.

1 change: 0 additions & 1 deletion src/index.js

This file was deleted.

1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './types';
32 changes: 0 additions & 32 deletions src/types/__tests__/graphql_fauna_id_type.test.js

This file was deleted.

30 changes: 30 additions & 0 deletions src/types/__tests__/graphql_fauna_id_type.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import GraphQLFaunaIdType from '../graphql_fauna_id_type';
import { query as q } from 'faunadb';

const v = require('faunadb/src/values');
// const { toJSON, parseJSON } = require('faunadb/src/_json');
const FooId = new GraphQLFaunaIdType({
name: 'FooId',
className: 'foo',
});

describe('serialize id', () => {
it('serialize', () => {
// const s = new q.Ref('asdf')
const ref = new v.Ref('foo', new v.Ref('foo', new v.Ref('foo')));
// console.log(new v.Ref('112341', new v.Ref('class', new v.Ref('foo'))))
// console.log(toJSON(q.Ref(q.Class('foo'), '1'))
// console.log(parseJSON(toJSON(q.Ref(q.Class('foo'), '1')))
// const s = parseJSON(toJSON(q.Ref(q.Class('foo'), '1')))
// console.log(s)
const res = FooId.serialize(ref);
expect(res).toBe('foo');
});
});

// describe('parse timestamp', () => {
// test('parse iso8601 nanosecond precision', () => {
// const res = GraphQLTimestampType.parseValue(ISO_STRING_N)
// expect(res).toEqual(TIMESTAMP_N)
// })
// })
57 changes: 0 additions & 57 deletions src/types/__tests__/graphql_fauna_timestamp_type.test.js

This file was deleted.

57 changes: 57 additions & 0 deletions src/types/__tests__/graphql_fauna_timestamp_type.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import GraphQLTimestampType from '../graphql_fauna_timestamp_type';

const TIMESTAMP_N = 1542718688123456;
const TIMESTAMP_MS = 1542718688123;
const TIMESTAMP_S = 1542718688;
const ISO_STRING_N = '2018-11-20T12:58:08.123456Z';
const ISO_STRING_MS = '2018-11-20T12:58:08.123Z';
const ISO_STRING_S = '2018-11-20T12:58:08Z';

describe('serialize timestamp', () => {
test('serialice nanosecond precision ts', () => {
const res = GraphQLTimestampType.serialize(TIMESTAMP_N);
expect(res).toBe(ISO_STRING_N);
});

test('serialice millisecond precision ts', () => {
const res = GraphQLTimestampType.serialize(TIMESTAMP_MS);
expect(res).toBe(ISO_STRING_MS);
});

test('serialice second precision ts', () => {
const res = GraphQLTimestampType.serialize(TIMESTAMP_S);
expect(res).toBe(ISO_STRING_S);
});
});

describe('parse timestamp', () => {
test('parse iso8601 nanosecond precision', () => {
const res = GraphQLTimestampType.parseValue(ISO_STRING_N);
expect(res).toEqual(TIMESTAMP_N);
});

test('parse iso8601 millisecond precision', () => {
const res = GraphQLTimestampType.parseValue(ISO_STRING_MS);
expect(res).toEqual(TIMESTAMP_MS * 1000);
});

test('parse iso8601 second precision', () => {
const res = GraphQLTimestampType.parseValue(ISO_STRING_S);
expect(res).toEqual(TIMESTAMP_S * 1000000);
});

test('parse unix nanosecond precision', () => {
const res = GraphQLTimestampType.parseValue(TIMESTAMP_N);
expect(res).toEqual(TIMESTAMP_N);
});

test('parse unix millisecond precision', () => {
const res = GraphQLTimestampType.parseValue(TIMESTAMP_MS);
expect(res).toEqual(TIMESTAMP_MS * 1000);
});

test('parse unix second precision', () => {
const res = GraphQLTimestampType.parseValue(TIMESTAMP_S);
expect(res).toEqual(TIMESTAMP_S * 1000000);
});
});
File renamed without changes.
20 changes: 0 additions & 20 deletions src/types/graphql_fauna_batch_type.js

This file was deleted.

26 changes: 26 additions & 0 deletions src/types/graphql_fauna_batch_type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
GraphQLObjectType,
GraphQLObjectTypeConfig,
GraphQLList,
GraphQLType,
} from 'graphql';

class GraphQLFaunaBatch<TSource, TContext> extends GraphQLObjectType {
constructor({
name,
type,
fields = {},
}: GraphQLObjectTypeConfig<TSource, TContext> & { type: GraphQLType }) {
super({
name,
fields: () => ({
...fields,
items: {
type: new GraphQLList(type),
},
}),
});
}
}

export default GraphQLFaunaBatch;
Empty file.
Loading