8000 PostGraphQL 2 Beta by calebmer · Pull Request #145 · graphile/crystal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PostGraphQL 2 Beta #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 270 commits into from
Oct 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
270 commits
Select commit Hold shift + click to select a range
c9d4a3b
refactor(postgres): rename the introspection sql again
calebmer Aug 31, 2016
3ebc9db
test(*): fix tests
calebmer Aug 31, 2016
fb59cfd
refactor(tests): rename test files
calebmer Aug 31, 2016
5f88472
refactor(graphql): remove confusing argument spread
calebmer Sep 2, 2016
de3d3ed
feat(graphql): allow users to rename the node id field name
calebmer Sep 2, 2016
ae6d773
refactor(catalog): remove collection catalog dependency
calebmer Sep 2, 2016
5d44cd6
chore(*): upgrade dependencies
calebmer Sep 4, 2016
11e8b06
refactor(graphql): refactor GraphQL schema generation
calebmer Sep 4, 2016
89a6f4f
refactor(*): rename test watch script
calebmer Sep 4, 2016
847c70e
feat(package): add extra meta information
calebmer Sep 4, 2016
c41169f
test(*): fix tests
calebmer Sep 4, 2016
8000 ef4736d
test(graphql): start adding back tests
calebmer Sep 7, 2016
3fad50f
chore(*): add license
calebmer Sep 9, 2016
dee873c
refactor(tests): from ava to jest
calebmer Sep 10, 2016
1c0cd96
refactor(*): rename abstract catalog to inventory
calebmer Sep 10, 2016
f2b6cde
refactor(graphql): rename build context to build token
calebmer Sep 10, 2016
a75dcd1
refactor(graphql): move some files
calebmer Sep 10, 2016
09b3d14
refactor(postgres): create custom collection type
calebmer Sep 10, 2016
b92bee0
test(postgres): add tests for collection type
calebmer Sep 10, 2016
b85a84d
test(*): add PostGraphQL integration test
calebmer Sep 10, 2016
b43a461
feat(postgres): pluralize collection names
calebmer Sep 10, 2016
a78a036
test(postgres): fix broken test
calebmer Sep 10, 2016
e0efad3
style(postgres): swap out array syntax
calebmer Sep 10, 2016
1435a47
refactor(scripts): pass arguments to test script
calebmer Sep 11, 2016
422bce4
refactor(postgres): remove some collection class members
calebmer Sep 11, 2016
aab4dbd
tests(postgres): delete unused test
calebmer Sep 11, 2016
45a29f8
doc(postgres): add an inline comment
calebmer Sep 11, 2016
89a9696
refactor(inventory): remove automated interface tests
calebmer Sep 11, 2016
a6f322b
refactor(postgres): change Postgres inventory interop
calebmer Sep 11, 2016
2110b34
feat(postgres): add get object by name methods
calebmer Sep 11, 2016
6ce4bf1
refactor(postgres): change access methods for test utils
calebmer Sep 11, 2016
ce49034
refactor(tests): always use kitchen sink schema in tests
calebmer Sep 11, 2016
4a813e1
tests(postgres): add tests for PGCollection
calebmer Sep 12, 2016
3007893
style(postgres): delete removed code
calebmer Sep 16, 2016
bea0289
refactor(postgres): rename some types
calebmer Sep 16, 2016
6906200
feat(postgres): add constraint introspection
calebmer Sep 16, 2016
74ba1a0
refactor(interface): refactor from abstract classes to interfaces
calebmer Sep 16, 2016
95b7e53
refactor(examples): remove implicit namespacing
calebmer Sep 17, 2016
b5fafa6
feat(postgres): implement initial pg collection key
calebmer Sep 18, 2016
0d1f3c7
refactor(postgres): refactor some stuffs
calebmer Sep 19, 2016
db60e03
refactor(tests): fix test flakiness
calebmer Sep 19, 2016
7318a5e
feat(postgres): start implementing update
calebmer Sep 19, 2016
7c90045
refactor(postgres): expirements
calebmer Sep 20, 2016
07a6e58
refactor(interface): refactor types majorly
calebmer Sep 20, 2016
03185a9
tests(postgres): add tests for collection key updates
calebmer Sep 20, 2016
76c6a84
feat(postgres): add delete to collection key
calebmer Sep 20, 2016
950737a
tests(postgres): add another collection key delete test
calebmer Sep 20, 2016
0e50110
feat(postgres): integrate keys with collections
calebmer Sep 21, 2016
f3a73e3
feat(postgres): add id to rowId rename support
calebmer Sep 21, 2016
7f24899
refactor(interface): change some stuff preparing for relation impleme…
calebmer Sep 21, 2016
b288224
test(postgres): add test for `row_id` rename
calebmer Sep 21, 2016
807c93a
feat(postgres): add relations
calebmer Sep 21, 2016
e55ae32
doc(postgres): add todo comment
calebmer Sep 21, 2016
1a14669
feat(postgres): add collection paginator
calebmer Sep 23, 2016
c04367c
tests(postgres): add more cases to kitchen sink
calebmer Sep 23, 2016
9afd52e
test(postgres): add tests for collection paginator
calebmer Sep 23, 2016
394bfdc
test(postgraphql): add integration test setup
calebmer Sep 23, 2016
7ef8d37
refactor(package): move Jest preprocessor
calebmer Sep 23, 2016
f97c723
fix(examples): add missing namespace
calebmer Sep 24, 2016
7f14430
refactor(postgres): update pg types
calebmer Sep 24, 2016
5e87c7b
refactor(interface): refactor context to be a class
calebmer Sep 24, 2016
da3acef
feat(graphql): add GraphQL HTTP request handler
calebmer Sep 26, 2016
44692bb
feat(graphql): serve a favicon from GraphQL HTTP
calebmer Sep 26, 2016
61b38e9
feat(graphql): add GraphiQL to HTTP request handler
calebmer Sep 26, 2016
d723028
style(graphql): move requires
calebmer Sep 26, 2016
d8bd1bc
fix(test): fix test flakiness
calebmer Sep 26, 2016
ed6065d
fix(tests): fix flakiness, again…
calebmer Sep 26, 2016
b8704fb
test(postgraphql): add complex types test
calebmer Sep 26, 2016
2878b95
chore(*): add better server development experience
calebmer Sep 26, 2016
4b99a52
doc(graphql): add documentation for a function
calebmer Sep 26, 2016
dd75e37
fix(graphql): fix compile errors
calebmer Sep 26, 2016
0588871
fix(graphql): add transform input value function
calebmer Sep 26, 2016
9457e86
refactor(package): rename start script to dev
calebmer Sep 26, 2016
de993ec
test(postgres): add new compound key naming case to kitchen sink
calebmer Sep 26, 2016
145cf6e
fix(postgres): fix Postgres value handling logic
calebmer Sep 26, 2016
108116b
feat(graphql): debugs http requests
calebmer Sep 27, 2016
334ed45
doc(graphql): remove todos
calebmer Sep 27, 2016
1f3047b
refactor(graphql): remove paginator name from cursors
calebmer Sep 27, 2016
fada7f1
fix(graphql): fix id serialization and deserialization
calebmer Sep 27, 2016
7d0a42c
test(postgres): add comprehensive paginator tests
calebmer Sep 29, 2016
b2a7ab1
refactor(graphql): move GraphiQL to its own route
calebmer Sep 29, 2016
a45a869
fix(postgres): fix alias naming collision
calebmer Sep 29, 2016
2ccdb63
feat(postgres): add support for symbol identifiers to sql util
calebmer Sep 29, 2016
a277f08
test(postgraphql): add more integration tests
calebmer Sep 29, 2016
4d6518e
feat(graphql): add a root recursive field for Relay 1
calebmer Sep 29, 2016
7a37c80
feat(graphql): add create mutation
calebmer Sep 30, 2016
9919e3e
test(graphql): add some tests for create mutation
calebmer Sep 30, 2016
5a5ad3a
chore(typings): update GraphQL typings
calebmer Sep 30, 2016
a89d89f
fix(graphql): fix create mutation return type
calebmer Sep 30, 2016
4fbb94e
feat(graphql): add connection conditions
calebmer Sep 30, 2016
3534274
test(postgraphql): add pageInfo to connections test
calebmer Sep 30, 2016
60b63d0
feat(graphql): add descriptions
calebmer Sep 30, 2016
ff2b62d
doc(interface): add TODO
calebmer Sep 30, 2016
189d942
refactor(graphql): move collection mutations
calebmer Sep 30, 2016
90fcd29
refactor(graphql): move collection key input creation to own file
calebmer Sep 30, 2016
cc9d5d9
refactor(graphql): rename a function
calebmer Sep 30, 2016
d56b4f1
refactor(graphql): move some modules
calebmer Sep 30, 2016
8d10806
feat(graphql): add delete by collection key mutation
calebmer Sep 30, 2016
74922ee
feat(graphql): add delete by collection mutation
calebmer Sep 30, 2016
69f16ad
feat(graphql): add deleted id to delete mutations
calebmer Sep 30, 2016
1d3eb5d
feat(graphql): add collection update mutation
calebmer Sep 30, 2016
8c7f6dc
refactor(postgraphql): splits integration tests in two
calebmer Sep 30, 2016
8f05e93
feat(graphql): add collection key update mutations
calebmer Sep 30, 2016
9c78fd8
test(*): add some more tests
calebmer Oct 1, 2016
90571c1
refactor(test): improve test performance
calebmer Oct 1, 2016
fbb968e
refactor(graphql): refactor idSerde to use collections
calebmer Oct 1, 2016
03cc3af
refactor(graphql): rename some functions
calebmer Oct 1, 2016
f848686
refactor(interface): refactor paginator in preparation for procedures
calebmer Oct 1, 2016
4a10779
refactor(interface): re-classify paginator
calebmer Oct 1, 2016
d9f307e
feat(interface): add procedures
calebmer Oct 1, 2016
1564223
feat(postgres): singularize the collection type name
calebmer Oct 2, 2016
9c4953d
feat(graphql): add procedure single output
calebmer Oct 2, 2016
dbb6e3f
feat(graphql): add paginator mutation procedure support
calebmer Oct 2, 2016
eecda05
feat(postgres): start Postgres procedure support
calebmer Oct 2, 2016
1f185f5
doc(interface): add ideas folder
calebmer Oct 2, 2016
e9618b7
style(interface): reorder before/after cursor
calebmer Oct 2, 2016
5424e0d
doc(interface): add some TODOs
calebmer Oct 2, 2016
9605749
refactor(graphql): rename things and add hooks
calebmer Oct 3, 2016
f8e96f3
refactor(postgraphql): change how schema is created
calebmer Oct 3, 2016
7b19e88
doc(postgraphql): add docs to function
calebmer Oct 3, 2016
5290042
refactor(*): refactor context
calebmer Oct 3, 2016
d844ae9
feat(postgres): add procedures to introspection
calebmer Oct 3, 2016
138d768
refactor(postgres): passs down config
ferdinandsalis Oct 3, 2016
c3cdaec
feat(postgraphql): add first rough stab at cli
ferdinandsalis Oct 3, 2016
9d51ea6
feat(postgraphql): add schema for mutation procedures
calebmer Oct 3, 2016
91e4ab7
fix(test): fix kitchen sink schema mutation procedure
calebmer Oct 3, 2016
a1db5d4
feat(postgres): make pg catalog types immutable
calebmer Oct 3, 2016
655a7b1
feat(query): add basic procedure mutation and query fields
calebmer Oct 5, 2016
ba1d5e9
chore(package): update Jest to v16
calebmer Oct 5, 2016
b700ae4
style(postgraphql): collapse import statement
calebmer Oct 5, 2016
17908d6
refactor(postgraphql): move procedure hook functions
calebmer Oct 5, 2016
281bbdc
refactor(test): rename schema functions
calebmer Oct 6, 2016
07f7edc
test(postgraphql): add delete mutation test
calebmer Oct 6, 2016
d36af82
refactor(postgres): rename function
calebmer Oct 6, 2016
8b1db11
test(postgraphql): make http tests run again
calebmer Oct 6, 2016
ed12384
test(postgraphql): add create mutation test
calebmer Oct 6, 2016
ddb891e
test(postgraphql): add mutation update test
calebmer Oct 6, 2016
d6e4585
refactor(graphql): rename root recursive query field
calebmer Oct 6, 2016
b1ba4c8
feat(postgraphql): add mutation procedure execution
calebmer Oct 6, 2016
7da49f8
test(postgraphql): add Postgres array to tests
calebmer Oct 6, 2016
85f2e4e
feat(postgraphql): add resolution for single return procedures
calebmer Oct 6, 2016
1615982
fix(postgraphql): add extra snapshot changes after last commit
calebmer Oct 6, 2016
62c4212
fix(postgraphql): fix HTTP server
calebmer Oct 6, 2016
156fc46
feat(postgraphql): add connection procedure execution
calebmer Oct 6, 2016
a39fab2
feat(postgraphql): add computed procedure fields
calebmer Oct 7, 2016
5fd1e0e
feat(postgraphql): add library interface
calebmer Oct 7, 2016
961f011
fix(graphql): use `typeof` undefined check instead of equality
calebmer Oct 7, 2016
eb88285
feat(postgraphql): add custom handling of the JSON type
calebmer Oct 7, 2016
dbe0468
fix(postgres): fix domain types nullability
calebmer Oct 7, 2016
160a4ce
doc(graphql): add docs for the build token
calebmer Oct 7, 2016
a6dce4a
feat(graphql): add dynamic json option
calebmer Oct 7, 2016
4a6b103
feat(graphql): add related collections to create mutation payload
calebmer Oct 7, 2016
a07508c
style(graphql): change JSON type name to Json
calebmer Oct 7, 2016
9af31b4
feat(graphql): add related tail collection fields to all collection m…
calebmer Oct 7, 2016
fe19307
fix(postgraphql): fix procedure defaults call
calebmer Oct 7, 2016
c830f79
feat(postgres): add support for Postgres range types
calebmer Oct 7, 2016
8078896
refactor(postgres): add more docs and stuff to ranges
calebmer Oct 8, 2016
31b7e1e
fix(postgres): fix some broken things
calebmer Oct 8, 2016
464ba71
feat(postgraphql): add head to tail relation selection
calebmer Oct 8, 2016
248e823
refactor(postgraphql): rename legacy ids to classic ids
calebmer Oct 8, 2016
ee57864
feat(postgres): better handling of time types
calebmer Oct 8, 2016
5977e8c
feat(postgraphql): add related fields to mutation top level for Relay 1
calebmer Oct 8, 2016
7e41f18
fix(interface): fix relation inventory key name
calebmer Oct 8, 2016
9e180ed
fix(postgres): fix the handling for smallint and money types
calebmer Oct 8, 2016
79b6846
feat(postgraphql): finish up cli
calebmer Oct 8, 2016
69dc104
doc(postgraphql): add some docs to the CLI
calebmer Oct 8, 2016
857ccb7
chore(package): optimize development workflow
calebmer Oct 9, 2016
7eea049
style(*): add TSLint
calebmer Oct 9, 2016
c3ae332
feat(postgraphql): add authorization
calebmer Oct 9, 2016
238d7a2
fix(test): fix failures caused by linting
calebmer Oct 9, 2016
4d53c9b
refactor(postgraphql): refactor procedure hooks
calebmer Oct 9, 2016
3272a31
refactor(graphql): remove always add collection types
calebmer Oct 9, 2016
0565429
feat(postgraphql): add authentication support
calebmer Oct 9, 2016
337c726
refactor(package): rename PostGraphQL CLI to main.js
calebmer Oct 9, 2016
0d807a3
chore(package): add beta to version
calebmer Oct 9, 2016
0acf0bc
fix(postgraphql): hide unused demo option
calebmer Oct 9, 2016
f8b2d42
feat(postgraphql): improve type identifier parsing
calebmer Oct 9, 2016
8f49723
test(postgraphql): add tests for authentication feature
calebmer Oct 9, 2016
a288bb4
test(postgraphql): add information_schema test
calebmer Oct 9, 2016
24b7840
fix(postgraphql): fix support for information_schema and pg_catalog
calebmer Oct 9, 2016
f1903d8
doc(*): add back docs
calebmer Oct 9, 2016
03092fc
doc(examples): add example documentation
calebmer Oct 9, 2016
4fe2c23
style(package): change some package.json fields
calebmer Oct 9, 2016
c3abb4c
style(graphql): fix lint errors
calebmer Oct 9, 2016
0de9ad3
fix(test): fix test failures
calebmer Oct 9, 2016
e1cd793
fix(package): add some more npm ignores
calebmer Oct 9, 2016
a485700
fix(package): refactor package exports
calebmer Oct 10, 2016
594b554
feat(graphql): implement Node for top level query field
calebmer Oct 10, 2016
2ab3aa6
feat(postgraphql): add an offset argument to pagination
calebmer Oct 10, 2016
0312d2e
chore(package): bump version
calebmer Oct 10, 2016
df3f4b0
fix(graphql): fix not null has default case
calebmer Oct 10, 2016
71b3961
chore(package): version bump
calebmer Oct 10, 2016
be2e8a7
fix(postgres): add cast information for composite types
calebmer Oct 12, 2016
fdd01f5
chore(package): bump version
calebmer Oct 12, 2016
1e0e5b4
feat(postgres): improve collection key performance
calebmer Oct 13, 2016
ea16735
fix(postgres): fix drop column introspection error
calebmer Oct 13, 2016
aea9256
chore(package): bump version
calebmer Oct 13, 2016
49308e1
style(postgres): fix lint error
calebmer Oct 13, 2016
ff7be28
chore(package): add continuous integration
calebmer Oct 13, 2016
7c6436f
fix(package): fix Travis format
calebmer Oct 13, 2016
2dd2016
fix(package): remove prepublish script for ci
calebmer Oct 13, 2016
6ce633e
fix(package): fix ignored build script
calebmer Oct 13, 2016
bf7eedb
fix(package): remove prepublish script again
calebmer Oct 13, 2016
5b8b043
fix(postgres): use attisdropped in introspection
calebmer Oct 13, 2016
06f1859
style(ci): add debuggings
calebmer Oct 13, 2016
b230763
fix(graphql): fix file name casing
calebmer Oct 13, 2016
de33952
test(postgraphql): remove information_schema and pg_catalog tests
calebmer Oct 14, 2016
012f76c
feat(postgraphql): add missing descriptions
calebmer Oct 14, 2016
5819c02
fix(test): fix timezone disparities in tests
calebmer Oct 14, 2016
9ee7f1e
fix(test): data ordering error opportunity
calebmer Oct 14, 2016
6d8a4b9
chore(ci): cache node_moduels
calebmer Oct 14, 2016
8e4c3f5
fix(ci): remove old Node.js, add second Postgres version
calebmer Oct 14, 2016
73173db
fix(ci): multiple postgres versions
calebmer Oct 14, 2016
ccbbbd8
style(graphql): fix naming and comments
langpavel Oct 14, 2016
3f728b0
Merge pull request #155 from langpavel/fix-typos
calebmer Oct 14, 2016
c857057
refactor(postgraphql): change how authentication tokens work
calebmer Oct 14, 2016
5aff8f7
refactor(graphql): move condition fields into an object
calebmer Oct 14, 2016
d488050
fix(ci): increase timeout interval for flaky tests
calebmer Oct 14, 2016
852cf75
fix(ci): increase the timeout interval for another test
calebmer Oct 14, 2016
4093237
fix(ci): increase the timeout for more test suites
calebmer Oct 14, 2016
398517f
feat(ci): add caching for nvm
calebmer Oct 14, 2016
3e24703
refactor(*): use consistent acronym casing
calebmer Oct 14, 2016
41d4363
refactor(postgraphql): move CLI file
calebmer Oct 14, 2016
3f69058
fix(postgraphql): fix broken cli import
calebmer Oct 14, 2016
878779f
feat(postgraphql): allow single schema
calebmer Oct 14, 2016
b9318a4
docs(interface): add thoughtcode for new type system
calebmer Oct 14, 2016
3a58adf
fix(cli): package.json import
calebmer Oct 14, 2016
a330f3c
fix(interface): fix interface json type name
calebmer Oct 14, 2016
3125dfc
chore(test): update database introspection
calebmer Oct 14, 2016
e7dda5c
chore(package): bump version
calebmer Oct 14, 2016
1b375b9
fix(tests): fix incorrect environment variable casing
calebmer Oct 14, 2016
56d9a23
feat(postgraphql): log Postgres role in HTTP handler
calebmer Oct 14, 2016
399a0b8
chore(package): bump version
calebmer Oct 14, 2016
e081040
docs(library): explain schema concept is single value
calebmer Oct 15, 2016
3159859
fix(graphql): don’t allow the use of cursors with offset
calebmer Oct 14, 2016
76e6938
chore(package): bump version
calebmer Oct 15, 2016
7049d9b
docs(examples): initial schema design documentation
calebmer Oct 15, 2016
2df0222
test(postgraphql): add forum example schema to tests
calebmer Oct 15, 2016
b4245c3
doc(examples): make some edits
calebmer Oct 15, 2016
3aa7f8b
doc(examples): add table of contents
calebmer Oct 15, 2016
787bbe4
doc(examples): change intro wording
calebmer Oct 15, 2016
fb3071c
chore(examples): update schema
calebmer Oct 15, 2016
7f53133
test(postgraphql): remove forum example schema test
calebmer Oct 15, 2016
6eda606
doc(examples): fix some spelling/clarity issues
calebmer Oct 15, 2016
3888eea
feat(ci): build demo database on ci success
calebmer Oct 16, 2016
0f3b6df
refactor(postgraphql): add TODOs for demo flag
calebmer Oct 16, 2016
e9c12df
docs(procedures): clarify that computed fields must be stable
calebmer Oct 16, 2016
6c97ed3
fix(graphql): empty set cursors
calebmer Oct 16, 2016
e24f884
fix(postgres): fix condition classic ids handling
calebmer Oct 16, 2016
5c1120d
chore(package): bump version
calebmer Oct 16, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

11 changes: 0 additions & 11 deletions .eslintrc

This file was deleted.

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
node_modules
npm-debug.log
dist/
npm-debug.log*
build/
TODO.md
16 changes: 16 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.DS_Store
node_modules
npm-debug.log*
TODO.md
.editorconfig
tsconfig.json
tslint.json
.vscode
src
build/**/__tests__
build/**/__mocks__
typings
scripts
examples
docs
resources/jest-*
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ language: node_js

node_js:
- "6"
- "5"

addons:
postgresql: "9.4"

env:
TEST_DB: postgres://localhost:5432/travis
TEST_PG_URL: postgres://localhost:5432/travis

cache:
directories:
- node_modules
- $NVM_DIR

script:
- npm run lint
- npm test
- scripts/ci

after_success:
- "cd examples/forum && scripts/run-schema-demo $DEMO_PG_URL"
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"typescript.tsdk": "./node_modules/typescript/lib",
"eslint.enable": false
}
51 changes: 29 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,30 @@ First install using npm:
npm install -g postgraphql
```

and then just run it!
and then just run it! By default, PostGraphQL will connect to your local database at `postgres://localhost:5432` and introspect the `public` schema.

```bash
postgraphql postgres://localhost:5432/mydb --schema forum --development
postgraphql
```

For more information run:
For information about how to change these defaults, just run:

```bash
postgraphql --help
```

Check out the **[forum example][]** for a demo of PostGraphQL in action.
You can also use PostGraphQL as native HTTP, Connect, Express, or Koa middleware. Just import `postgraphql`:

Also check out relevant [documentation links](#documentation).
```js
import { createServer } from 'http'
import postgraphql from 'postgraphql'

createServer(postgraphql())
```

For more information around using PostGraphQL as a library, and the options the API expects read the [library usage documentation article](https://github.com/calebmer/postgraphql/blob/master/docs/library.md).

Also make sure to check out the **[forum example][]** for a demo of a PostGraphQL compliant schema.

[forum example]: https://github.com/calebmer/postgraphql/tree/master/examples/forum

Expand All @@ -62,12 +71,14 @@ Can query relations like so:

```graphql
{
postNodes {
nodes {
headline
body
author: userByAuthorId {
name
allPosts {
edges {
node {
headline
body
author: userByAuthorId {
name
}
}
}
}
Expand Down Expand Up @@ -98,9 +109,12 @@ And queried through GraphQL like this:
hasNextPage
}
totalCount
nodes {
headline
body
edges {
cursor
node {
headline
body
}
}
}
}
Expand Down Expand Up @@ -192,18 +206,11 @@ The specific specs PostGraphQL implements are:
* * *

## Documentation
- [Using PostGraphQL as ExpressJS or Connect middleware.](https://github.com/calebmer/postgraphql/blob/master/docs/library.md)
- [Using PostGraphQL as Express, Connect, or Koa middleware.](https://github.com/calebmer/postgraphql/blob/master/docs/library.md)
- [Adding advanced queries to PostGraphQL.](https://github.com/calebmer/postgraphql/blob/master/docs/advanced-queries.md)
- [Using PostgreSQL functions to extend your PostGraphQL schema.](https://github.com/calebmer/postgraphql/blob/master/docs/procedures.md)
- [A crash course in PostgreSQL roles for PostGraphQL.](https://github.com/calebmer/postgraphql/blob/master/docs/anonymous-role.md)

## Roadmap
In the future, things PostGraphQL will be able to do will include:

- Authentication using PostgreSQL roles.
- Whitelisted queries in production.
- Subscriptions using the PostgreSQL [`NOTIFY`][pg-notify] feature.

## Evaluating PostGraphQL For Your Project
Hopefully you’ve been convinced that PostGraphQL serves an awesome GraphQL API, but now let’s take a more critical look at whether or not you should adopt PostGraphQL for your project.

Expand Down
10 changes: 5 additions & 5 deletions docs/anonymous-role.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ You can make any number of PostgreSQL roles with [`CREATE ROLE`](https://www.pos
PostgreSQL roles are also hierarchical. That is you can “grant” roles to other roles. For example if I had role `editor` which could change the data in our database and role `admin`, if I granted the `editor` role to `admin` with the command:

```sql
GRANT editor TO admin;
grant editor to admin;
```

Then the `admin` role would have the same permissions the `editor` role has. The `admin` role would also be able to *change* its role to the `editor` role. This means for the rest of the session you don’t have any `admin` permissions, but only permissions given to the `editor` role.

In PostgreSQL you also have the idea of a user. A user is just a role that can login. So for example, the following are equivalent as the create an `admin` role that can log in (or a user):

```sql
CREATE ROLE admin LOGIN;
CREATE USER admin;
create role admin login;
create user admin;
```

…and the following are also equivalent as they create a role that *can’t* log in:

```sql
CREATE ROLE editor;
CREATE ROLE editor NOLOGIN;
create role editor;
create role editor nologin;
```

“Logging in” just means we can use the role when authenticating in the PostgreSQL authentication section of the connection string. So with the above roles you could start a PostgreSQL connection with `postgres://admin@localhost:5432/mydb`, but not `postgres://editor@localhost:5432/mydb`.
Expand Down
32 changes: 22 additions & 10 deletions docs/library.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Using PostGraphQL as a Library
Some people may want to use PostGraphQL as a dependency of their current node projects. This is a functionality PostGraphQL intends to support. As long as you are using a server framework that supports [connect][]-styled middleware, you can use PostGraphQL as a dependency.
Some people may want to use PostGraphQL as 3D11 a dependency of their current node projects and mount the PostGraphQL instance on their own web server. For this usecase PostGraphQL exports itself as a HTTP middleware for the following HTTP frameworks:

To use PostGraphQL as a library just do the following:
- [`connect`](http://npmjs.com/connect)
- [`express`](https://www.npmjs.com/package/express)
- [`koa` 2.0](https://www.npmjs.com/package/koa)
- [Vanilla `http`](https://nodejs.org/api/http.html)

To use PostGraphQL with `express` just do the following:

```js
import express from 'express'
Expand All @@ -23,23 +28,30 @@ import postgraphql from 'postgraphql'
http.createServer(postgraphql('postgres://localhost:5432')).listen(3000)
```

To import the function with CommonJS:
To import the middleware with CommonJS:

```js
var postgraphql = require('postgraphql').default
var postgraphql = require('postgraphql').postgraphql
```

The API for creating handlers is as follows:
The `postgraphql` function can take the following arguments:

## postgraphql(pgConfig, schemaName? = 'public', options)
## postgraphql(pgConfig?, schemaName? = 'public', options?)
Arguments include:

- **`pgConfig`**: An object or string that will be passed to the [`pg`][] library and used to connect to a PostgreSQL backend.
- **`schemaName`**: A string which specifies the PostgreSQL schema you will be serving with PostGraphQL. The default schema is the `public` schema.
- **`schemaName`**: A string which specifies the PostgreSQL schema you will be serving with PostGraphQL. The default schema is the `public` schema. May be an array for multiple schemas.
- **`options`**: An object containing other miscellaneous options. Options could be:
- `secret`: The secret for your application. This enables PostGraphQL’s authorization features. Make it something secure and obscure!
- `development`: Enables development features like GraphiQL and more descriptive error formatting.
- `log`: If true, PostGraphQL will log every request using the dev style of [morgan][].
- `classicIds`: Enables classic ids for Relay 1 support. Instead of using the field name `__id` for globally unique ids, PostGraphQL will instead use the field name `id` for its globally unique ids. This means that table `id` columns will also get renamed to `rowId`.
- `dynamicJson`: Setting this to `true` enables dynamic JSON which will allow you to use any JSON as input and get any arbitrary JSON as output. By default JSON types are just a JSON string.
- `graphiql`: Set this to `true` to enable the GraphiQL interface.
- `graphqlRoute`: The endpoint the GraphQL executer will listen on. Defaults to `/graphql`.
- `graphiqlRoute`: The endpoint the GraphiQL query interface will listen on (**NOTE:** GraphiQL will not be enabled unless the `graphiql` option is set to `true`). Defaults to `/graphiql`.
- `pgDefaultRole`: The default Postgres role to use. If no role was provided in a provided JWT token, this role will be used.
- `jwtSecret`: The secret for your JSON web tokens. This will be used to verify tokens in the `Authorization` header, and signing JWT tokens you return in procedures.
- `jwtPGTypeIdentifier`: The Postgres type identifier for the compound type which will be signed as a JWT token if ever found as the return type of a procedure. Can be of the form: `my_schema.my_type`. You may use quotes as needed: `"my-special-schema".my_type`.
- `disableQueryLog`: Turns off GraphQL query logging. By default PostGraphQL will log every GraphQL query it processes along with some other information. Set this to `true` to disable that feature.
- `enableCors`: Enables some generous CORS settings for the GraphQL endpoint. There are some costs associated when enabling this, if at all possible try to put your API behind a reverse proxy.

[connect]: https://www.npmjs.com/connect
[express]: https://www.npmjs.com/express
Expand Down
71 changes: 0 additions & 71 deletions docs/naming.md

This file was deleted.

28 changes: 10 additions & 18 deletions docs/procedures.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ $$ language sql immutable strict;
By default, a procedure is “volatile” and PostGraphQL will treat it as a mutation. So for example, a procedure defined as:

```sql
CREATE FUNCTION my_function(a int, b int) RETURNS int AS $$ … $$ LANGUAGE SQL;
create function my_function(a int, b int) returns int as $$ … $$ language sql;
```

Is equivalent to a procedure defined as:

```sql
CREATE FUNCTION my_function(a int, b int) RETURNS int AS $$ … $$ LANGUAGE SQL VOLATILE;
create function my_function(a int, b int) returns int as $$ … $$ language sql volatile;
```

From the PostgreSQL docs:
Expand All @@ -123,15 +123,15 @@ Always look at the documentation in GraphiQL to find all the parameters you may
Similar to how you use `VOLATILE` to specify a mutative procedure, a query procedure can be specified using `IMMUTABLE` or `STABLE` identifiers. For example:

```sql
CREATE FUNCTION my_function(a int, b int) RETURNS int AS $$ … $$ LANGUAGE SQL STABLE;
create function my_function(a int, b int) returns int as $$ … $$ language sql stable;

-- or…

CREATE FUNCTION my_function(a int, b int) RETURNS int AS $$ … $$ LANGUAGE SQL IMMUTABLE;
create function my_function(a int, b int) returns int as $$ … $$ language sql immutable;

-- or if you wanted to return a row from a table…

CREATE FUNCTION my_function(a int, b int) RETURNS my_table AS $$ … $$ LANGUAGE SQL STABLE;
create function my_function(a int, b int) returns my_table as $$ … $$ language sql stable;
```

From the PostgreSQL docs:
Expand Down Expand Up @@ -169,7 +169,7 @@ To create a function that returns a connection, use the following SQL:
```sql
-- Assuming we already have a table named `person`…

CREATE FUNCTION my_function(a int, b int) RETURNS SETOF person AS $$ … $$ LANGUAGE SQL;
create function my_function(a int, b int) returns setof person as $$ … $$ language sql;
```

To query a set in PostGraphQL, you would use all of the connection arguments you are familiar with in addition to the arguments to your procedure. For example:
Expand All @@ -196,23 +196,15 @@ For more information on constructing advanced queries, read [this article][advan
[advanced-queries]: https://github.com/calebmer/postgraphql/blob/master/docs/advanced-queries.md

## Computed Columns
PostGraphQL also provides support for computed columns. In order to define a computed column, just write a function that is `STABLE` or `IMMUTABLE` and has a table in your schema as its first argument. For example:
PostGraphQL also provides support for computed columns. In order to define a computed column, just write a function that is `STABLE` or `IMMUTABLE`, has a table in your schema as its first argument, and the name starts with the table’s name. For example:

```sql
CREATE FUNCTION full_name(person person) RETURNS text AS $$
create function person_full_name(person person) returns text as $$
select person.given_name || ' ' || person.family_name
$$ LANGUAGE SQL;
$$ language sql stable;
```

Will create a computed column for your table named `person`. If you want, you can also prefix your computed procedure’s name with your table name. This is helpful when you want to avoid namespacing clashes but it is not required.

```sql
-- PostGraphQL will treat this the same as the procedure above.

CREATE FUNCTION person_full_name(person person) RETURNS text AS $$
select person.given_name || ' ' || person.family_name
$$ LANGUAGE SQL;
```
Will create a computed column for your table named `person`.

To query these in the PostGraphQL schema, its pretty intuitive:

Expand Down
Loading
0