It's possible my procedure is invalid or returning invalid results.
This procedure
create or replace function account.authenticate(email text, password text)
returns account.auth_response_data
AS $$
declare
credentials account_private.credentials;
profile account.profile;
begin
select c.* into credentials
from account_private.credentials as c
where c.email = $1;
select p.* into profile
from account.profile as p
where p.id = credentials.profile_id;
if credentials.password <> crypt(password, credentials.password) then
-- FIXME: update failed login count for this IP addres
return null;
end if;
-- FIXME: update last login time and IP address
return (profile, ('evercast_account', credentials.profile_id)::account.jwt)::account.auth_response_data;
end;
$$
LANGUAGE 'plpgsql' VOLATILE
This query:
mutation Authentication {
authenticate(input: {email:"chad@adsfasdf", password:"asdfasdfasdf"}) {
authResponseDatum {
jwt
}
}
}
This error
``
{
"errors": [
{
"message": "Type.getFields is not a function",
"locations": [
{
"line": 14,
"column": 3
}
],
"path": [
"authenticate"
]
}
],
"data": null
}
Guessing it has something to do with the below error.
Error: Schema must contain unique named types but contains multiple types named "Profile".
at invariant (/opt/app/node_modules/graphql/jsutils/invariant.js:19:11)
at typeMapReducer (/opt/app/node_modules/graphql/type/schema.js:190:29)
at /opt/app/node_modules/graphql/type/schema.js:216:20
at Array.forEach (native)
at typeMapReducer (/opt/app/node_modules/graphql/type/schema.js:207:27)
at Array.reduce (native)
at new GraphQLSchema (/opt/app/node_modules/graphql/type/schema.js:95:34)
at Object.createGqlSchema [as createGraphQLSchema] (/opt/app/node_modules/postgraphql/src/graphql/schema/createGqlSchema.ts:44:10)
at Object.
at step (/opt/app/node_modules/tslib/tslib.js:122:27)
My bad. DataGrip doesn't include schema names in the generated DDL when you go to edit a function, and so my changes weren't saving.
馃憤
Could still do with a better error message, so if you pin it down I'd welcome a PR.
@benjie I'm sorry, these are two separate queries. I really should not stay up all night working on code. This isn't quite solved, and I will update when I know more. The 2nd comment here is for a different query entirely.
The error is coming from GraphQL and not from Postgraph. It's either a schema introspection error or a fat-finger on my part. Looking into it
I think you can use --show-error-stack to get a better stack trace from the GraphQL error
Is there an equivalent config for the middleware?
If you can get hold of the errors you can grab their originalError property...
Yeah; it's just showErrorStack in the middleware:
Got it. Reloading containers. Would I catch originalError in exportPostGraphQLSchema or in postgraphql/http/createPostGraphQLHttpRequestHandler?
Pretty sure your error is coming from here:
Can you check in your node_modules folder that that file looks like that (specifically that it has the isCompositeType and !isAbstractType checks) - because if those pass then it should have getFields
oh, well, I'm guessing in http/createPostGraphQLHttpRequestHandler because you linked me there.
@benjie no I don't have that. My graphql-build/src/makeNewBuild.js has this on line 288:
if (fieldDataGenerators) {
const typeFields = Type.getFields();
"name": "graphql-build",
"version": "0.0.1-alpha9.3",
...
"name": "postgraphql-build",
"version": "0.0.1-alpha11.0",
...
"name": "postgraphql",
"version": "4.0.0-alpha2.0",
Ah, you're a pip behind:
https://unpkg.com/[email protected]/node8plus/makeNewBuild.js
I am? Or postgraphql@next is? This is the latest version I found, and it brought down its own deps
Unless I botched that. I'm asking as a sanity check not to be snarky.
Puring node modules, yarn.lock, removing from package.json, trying again.
This might be that I've simply not merged that fix into PostGraphQL yet; things are still changing pretty fast! I'll try and get a release out by the end of Monday; but in the mean time you can try overwriting graphql-build in your node_modules with the latest version of graphql-build... just don't run yarn again because it'll undo it 馃槈
Yeah, confirmed I've not released the latest postgraphql yet:
By end of day Monday?
Can I get a cold push to some branch in the next 15min? <3
It's okay I can hack this solution in place for now ;)
tyvm for showErrorStack it worked great. Should be able to debug much easier now :D
I'm just pushing an untested postgraphql@next; I suspect it will be fine...
Done; see if that fixes it for you 馃憤
"name": "postgraphql",
"version": "4.0.0-alpha2.1",
...
"name": "postgraphql-build",
"version": "0.0.1-alpha11.1",
...
"name": "graphql-build",
"version": "0.0.1-alpha9.3",
graphql-build unchanged so not fixed
Have you manually installed your own graphql-build? If so I suspect your versions are conflicting and that postgraphql-build has it's own internal version?
https://unpkg.com/[email protected]/package.json
"graphql-build": "^0.0.1-alpha11.1",
I have not manually installed my own graphql-build.
~/api$ rm -rf node_modules
~/api$ rm yarn.lock
~/api$ cat package.json
{
"name": "api",
"version": "2.0.0",
"private": true,
"main": "src/index.js",
"scripts": {
"start": "nodemon src/index.js --exec babel-node --presets es2015,stage-2",
"build": "babel src -d dist --presets es2015,stage-2",
"lint": "standard --fix ./**/*.js"
},
"dependencies": {
"babel-cli": "^6.24.1",
"config": "^1.21.0",
"cookie-parser": "^1.4.3",
"dotenv": "^4.0.0",
"express": "^4.13.3",
"mongoose": "^4.6.5",
"node-fetch": "^1.7.1",
"postgraphql": "next",
"winston": "*"
},
"devDependencies": {
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"chai": "*",
"mocha": "^3.1.2",
"nodemon": "^1.11.0"
}
}
~/api$ yarn install
yarn install v0.27.5
warning ../package.json: No license field
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 3.38s.
I'll check more on my end. Thank you for confirming I have the wrong version :)
And thank you for pushing the new version so fast! I will update as soon as I know more
Maybe yarn why graphql-build will help?
Awesome, never heard of that one.
lotus@lappy:~/clevertech/creativ/api$ yarn why graphql-build
yarn why v0.27.5
warning ../package.json: No license field
[1/4] Why do we have the module "graphql-build"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info This module exists because "postgraphql#postgraphql-build" depends on it.
info Disk size without dependencies: "188kB"
info Disk size with unique dependencies: "1.35MB"
info Disk size with transitive dependencies: "8.26MB"
info Number of shared dependencies: 7
Done in 0.49s.
Checking postgraphql package.json now
~/api$ cat node_modules/postgraphql-build/package.json
{
"name": "postgraphql-build",
"version": "0.0.1-alpha11.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "scripts/test",
"prepublish": "mkdir -p node8plus node7minus && babel -s true --out-dir node8plus src && BABEL_ENV=node7minus babel -s true --out-dir node7minus src && flow-copy-source src node8plus",
"watch": "mkdir -p node8plus && babel -s true --watch --out-dir node8plus src"
},
"repository": {
"type": "git",
"url": "git+https://github.com/benjie/graphql-build.git"
},
"author": "Benjie Gillam <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/benjie/graphql-build/issues"
},
"dependencies": {
"babel-runtime": ">=6 <7",
"graphql-build": "^0.0.1-alpha11.1",
"graphql-build-pg": "^0.0.1-alpha11.1"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"flow-copy-source": "^1.2.0",
"jest": "20.0.4",
"jsonwebtoken": "^7.4.1"
},
"jest": {
"testRegex": "__tests__/.*\\.test\\.js$"
},
"files": [
"node8plus",
"node7minus",
"index.js"
]
}
Confirmed
So I wanted to get you a link but I can't find the file on github. In my postgraphql package's devDependencies is graphql^0.9.3 and I bet that might have something to do with it.
~/api$ cat node_modules/postgraphql/package.json
{
"name": "postgraphql",
"version": "4.0.0-alpha2.1",
"description": "A GraphQL schema created by reflection over a PostgreSQL schema 馃悩",
"author": "Caleb Meredith <[email protected]>",
"license": "MIT",
"homepage": "https://github.com/calebmer/postgraphql#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/calebmer/postgraphql.git"
},
"bugs": {
"url": "https://github.com/calebmer/postgraphql/issues"
},
"keywords": [
"graphql",
"postgres",
"schema",
"reflection",
"server",
"relay",
"connection"
],
"main": "build/index.js",
"bin": {
"postgraphql": "build/postgraphql/cli.js"
},
"scripts": {
"build": "./scripts/build",
"dev": "./scripts/dev",
"lint": "./scripts/lint",
"test": "./scripts/test",
"prepack": "./scripts/build"
},
"dependencies": {
"body-parser": "^1.15.2",
"chalk": "1.1.3",
"commander": "2.9.0",
"dataloader": "^1.2.0",
"debug": "^2.3.3",
"finalhandler": "^0.5.1",
"graphql": ">=0.6.0 <1.0.0",
"http-errors": "^1.5.1",
"jsonwebtoken": "^7.1.9",
"lodash": ">=3.5 <5",
"parseurl": "^1.3.1",
"pg": "^6.1.0",
"pg-connection-string": "^0.1.3",
"pg-minify": "^0.4.1",
"pg-sql2": "^1.0.0-alpha1.0",
"pluralize": "^3.0.0",
"postgraphql-build": "0.0.1-alpha11.1",
"postgres-interval": "^1.0.2",
"send": "^0.14.1",
"tslib": "^1.5.0"
},
"devDependencies": {
"@types/chalk": "^0.4.30",
"@types/change-case": "2.3.1",
"@types/commander": "^2.3.30",
"@types/debug": "0.0.29",
"@types/graphql": "^0.8.2",
"@types/jest": "^16.0.4",
"@types/jsonwebtoken": "<7.2.1",
"@types/node": "^7.0.4",
"@types/pluralize": "0.0.27",
"connect": "^3.5.0",
"express": "^4.14.0",
"graphiql": "^0.11.2",
"graphql": "^0.9.3",
"jest": "^18.1.0",
"nodemon": "^1.11.0",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react-scripts": "0.9.5",
"source-map-support": "^0.4.6",
"supertest": "^2.0.1",
"ts-node": "^2.0.0",
"tslint": "^4.2.0",
"typescript": "2.1.5"
},
"jest": {
"transform": {
".*": "<rootDir>/resources/jest-preprocessor.js"
},
"moduleFileExtensions": [
"ts",
"js"
],
"setupFiles": [
"<rootDir>/resources/jest-setup.js"
],
"browser": false,
"testEnvironment": "node",
"testPathDirs": [
"<rootDir>/src"
],
"testRegex": "/__tests__/[^.]+-test.(t|j)s$"
},
"files": [
"build",
"resources"
]
}
That's graphql, not graphql-build - 0.9.3 of graphql should be fine.
well this is interesting... note "latest" and "version" specifically
~/api$ yarn info graphql-build
yarn info v0.27.5
warning ../package.json: No license field
{ name: 'graphql-build',
description: 'Build a GraphQL schema from plugins',
'dist-tags':
{ next: '0.0.1-alpha1.0',
latest: '0.0.1-alpha11.2' },
versions:
[ '0.0.1-alpha1.0',
'0.0.1-alpha10.0',
'0.0.1-alpha11.0',
'0.0.1-alpha11.1',
'0.0.1-alpha11.2',
'0.0.1-alpha2.0',
'0.0.1-alpha2.2',
'0.0.1-alpha3.0',
'0.0.1-alpha3.1',
'0.0.1-alpha3.5',
'0.0.1-alpha3.6',
'0.0.1-alpha4.0',
'0.0.1-alpha5.0',
'0.0.1-alpha5.1',
'0.0.1-alpha6.0',
'0.0.1-alpha6.2',
'0.0.1-alpha6.3',
'0.0.1-alpha6.8',
'0.0.1-alpha7.0',
'0.0.1-alpha8.0',
'0.0.1-alpha8.1',
'0.0.1-alpha8.2',
'0.0.1-alpha8.3',
'0.0.1-alpha9.0',
'0.0.1-alpha9.1',
'0.0.1-alpha9.2',
'0.0.1-alpha9.3' ],
maintainers:
[ { name: 'benjie',
email: '[email protected]' } ],
time:
{ modified: '2017-07-28T13:32:11.664Z',
created: '2017-07-05T11:52:11.799Z',
'0.0.1-alpha1.0': '2017-07-05T11:52:11.799Z',
'0.0.1-alpha2.0': '2017-07-05T13:26:57.844Z',
'0.0.1-alpha2.2': '2017-07-05T14:59:54.327Z',
'0.0.1-alpha3.0': '2017-07-06T16:46:49.755Z',
'0.0.1-alpha3.1': '2017-07-07T08:11:54.571Z',
'0.0.1-alpha3.5': '2017-07-07T11:40:06.994Z',
'0.0.1-alpha3.6': '2017-07-07T16:27:04.678Z',
'0.0.1-alpha4.0': '2017-07-12T10:29:07.746Z',
'0.0.1-alpha5.0': '2017-07-12T10:32:40.914Z',
'0.0.1-alpha5.1': '2017-07-12T10:38:12.368Z',
'0.0.1-alpha6.0': '2017-07-12T15:53:42.969Z',
'0.0.1-alpha6.2': '2017-07-13T09:20:25.496Z',
'0.0.1-alpha6.3': '2017-07-13T10:06:58.444Z',
'0.0.1-alpha6.8': '2017-07-13T11:34:37.358Z',
'0.0.1-alpha7.0': '2017-07-13T13:00:25.211Z',
'0.0.1-alpha8.0': '2017-07-13T14:43:09.169Z',
'0.0.1-alpha8.1': '2017-07-13T14:58:13.196Z',
'0.0.1-alpha8.2': '2017-07-14T10:27:20.780Z',
'0.0.1-alpha8.3': '2017-07-14T16:33:23.192Z',
'0.0.1-alpha9.0': '2017-07-15T09:03:23.316Z',
'0.0.1-alpha9.1': '2017-07-15T11:27:10.434Z',
'0.0.1-alpha9.2': '2017-07-15T11:51:44.107Z',
'0.0.1-alpha9.3': '2017-07-16T19:48:18.187Z',
'0.0.1-alpha10.0': '2017-07-25T17:23:36.402Z',
'0.0.1-alpha11.0': '2017-07-26T11:38:29.515Z',
'0.0.1-alpha11.1': '2017-07-26T20:24:46.640Z',
'0.0.1-alpha11.2': '2017-07-28T13:32:11.664Z' },
homepage: 'https://github.com/benjie/graphql-build#readme',
keywords:
[ 'graphql',
'apollo',
'graphqljs',
'plugin',
'build',
'extension' ],
repository:
{ type: 'git',
url: 'git+https://github.com/benjie/graphql-build.git' },
author:
{ name: 'Benjie Gillam',
email: '[email protected]' },
bugs: { url: 'https://github.com/benjie/graphql-build/issues' },
license: 'MIT',
readmeFilename: 'README.md',
version: '0.0.1-alpha9.3',
main: 'index.js',
scripts:
{ test: 'jest',
prepublish: 'babel --out-dir lib src' },
dependencies:
{ 'babel-runtime': '>=6 <7',
debug: '>=2 <3',
'graphql-parse-resolve-info': '^0.0.1-alpha9.3',
'graphql-type-json': '^0.1.4' },
engines: { node: '>=4' },
devDependencies:
{ 'babel-cli': '^6.24.1',
jest: '^20.0.4' },
peerDependencies: { graphql: '>=0.9 <1' },
jest: { testRegex: '__tests__/.*\\.test\\.js$' },
files:
[ 'src',
'lib',
'index.js' ],
dist:
{ integrity: 'sha512-tTqtX4aGIhqps9lZSJcJGp4DQOzMTWvloMHjknKyb9EG19myewvPKa74MXlYpZjXbCzy2Slm5sHF/N9n/aCeHw==',
shasum: '5add832a92512c0b181bd6be97fe2862cad9713e',
tarball: 'https://registry.npmjs.org/graphql-build/-/graphql-build-0.0.1-alpha9.3.tgz' },
directories: {} }
Wait... what?
Is this why?
dist:
{ integrity: 'sha512-tTqtX4aGIhqps9lZSJcJGp4DQOzMTWvloMHjknKyb9EG19myewvPKa74MXlYpZjXbCzy2Slm5sHF/N9n/aCeHw==',
shasum: '5add832a92512c0b181bd6be97fe2862cad9713e',
tarball: 'https://registry.npmjs.org/graphql-build/-/graphql-build-0.0.1-alpha9.3.tgz' },
It's yarn that's at fault! Run the same command with npm: npm info graphql-build
woah, look at that...
{ name: 'graphql-build',
description: 'Build a GraphQL schema from plugins',
'dist-tags': { next: '0.0.1-alpha1.0', latest: '0.0.1-alpha11.2' },
versions:
[ '0.0.1-alpha1.0',
'0.0.1-alpha10.0',
'0.0.1-alpha11.0',
'0.0.1-alpha11.1',
'0.0.1-alpha11.2',
'0.0.1-alpha2.0',
'0.0.1-alpha2.2',
'0.0.1-alpha3.0',
'0.0.1-alpha3.1',
'0.0.1-alpha3.5',
'0.0.1-alpha3.6',
'0.0.1-alpha4.0',
'0.0.1-alpha5.0',
'0.0.1-alpha5.1',
'0.0.1-alpha6.0',
'0.0.1-alpha6.2',
'0.0.1-alpha6.3',
'0.0.1-alpha6.8',
'0.0.1-alpha7.0',
'0.0.1-alpha8.0',
'0.0.1-alpha8.1',
'0.0.1-alpha8.2',
'0.0.1-alpha8.3',
'0.0.1-alpha9.0',
'0.0.1-alpha9.1',
'0.0.1-alpha9.2',
'0.0.1-alpha9.3' ],
maintainers: [ 'benjie <[email protected]>' ],
time:
{ modified: '2017-07-28T13:32:11.664Z',
created: '2017-07-05T11:52:11.799Z',
'0.0.1-alpha1.0': '2017-07-05T11:52:11.799Z',
'0.0.1-alpha2.0': '2017-07-05T13:26:57.844Z',
'0.0.1-alpha2.2': '2017-07-05T14:59:54.327Z',
'0.0.1-alpha3.0': '2017-07-06T16:46:49.755Z',
'0.0.1-alpha3.1': '2017-07-07T08:11:54.571Z',
'0.0.1-alpha3.5': '2017-07-07T11:40:06.994Z',
'0.0.1-alpha3.6': '2017-07-07T16:27:04.678Z',
'0.0.1-alpha4.0': '2017-07-12T10:29:07.746Z',
'0.0.1-alpha5.0': '2017-07-12T10:32:40.914Z',
'0.0.1-alpha5.1': '2017-07-12T10:38:12.368Z',
'0.0.1-alpha6.0': '2017-07-12T15:53:42.969Z',
'0.0.1-alpha6.2': '2017-07-13T09:20:25.496Z',
'0.0.1-alpha6.3': '2017-07-13T10:06:58.444Z',
'0.0.1-alpha6.8': '2017-07-13T11:34:37.358Z',
'0.0.1-alpha7.0': '2017-07-13T13:00:25.211Z',
'0.0.1-alpha8.0': '2017-07-13T14:43:09.169Z',
'0.0.1-alpha8.1': '2017-07-13T14:58:13.196Z',
'0.0.1-alpha8.2': '2017-07-14T10:27:20.780Z',
'0.0.1-alpha8.3': '2017-07-14T16:33:23.192Z',
'0.0.1-alpha9.0': '2017-07-15T09:03:23.316Z',
'0.0.1-alpha9.1': '2017-07-15T11:27:10.434Z',
'0.0.1-alpha9.2': '2017-07-15T11:51:44.107Z',
'0.0.1-alpha9.3': '2017-07-16T19:48:18.187Z',
'0.0.1-alpha10.0': '2017-07-25T17:23:36.402Z',
'0.0.1-alpha11.0': '2017-07-26T11:38:29.515Z',
'0.0.1-alpha11.1': '2017-07-26T20:24:46.640Z',
'0.0.1-alpha11.2': '2017-07-28T13:32:11.664Z' },
homepage: 'https://github.com/benjie/graphql-build#readme',
keywords: [ 'graphql', 'apollo', 'graphqljs', 'plugin', 'build', 'extension' ],
repository:
{ type: 'git',
url: 'git+https://github.com/benjie/graphql-build.git' },
author: 'Benjie Gillam <[email protected]>',
bugs: { url: 'https://github.com/benjie/graphql-build/issues' },
license: 'MIT',
readmeFilename: 'README.md',
version: '0.0.1-alpha11.2',
main: 'index.js',
scripts:
{ test: 'jest',
prepublish: 'mkdir -p node8plus node7minus && babel -s true --out-dir node8plus src && BABEL_ENV=node7minus babel -s true --out-dir node7minus src && flow-copy-source src node8plus',
watch: 'mkdir -p node8plus && babel -s true --watch --out-dir node8plus src' },
dependencies:
{ 'babel-runtime': '>=6 <7',
debug: '>=2 <3',
'graphql-parse-resolve-info': '^0.0.1-alpha10.0',
'graphql-type-json': '^0.1.4' },
engines: { node: '>=4' },
devDependencies:
{ 'babel-cli': '^6.24.1',
'flow-copy-source': '^1.2.0',
jest: '^20.0.4' },
peerDependencies: { graphql: '>=0.9 <1' },
jest: { testRegex: '__tests__/.*\\.test\\.js$' },
files: [ 'node8plus', 'node7minus', 'index.js' ],
dist:
{ integrity: 'sha512-InWjm422EnOzWeg2m6jn7dSpNwiZK9n+IfjewBIyXUlcFUa4HyefJBCb82ACZNWKV9ZZvQ077b4Pead2cwBLMw==',
shasum: 'f2c8f21c7eb9efe08565ba58d47f1925b690bdaa',
tarball: 'https://registry.npmjs.org/graphql-build/-/graphql-build-0.0.1-alpha11.2.tgz' },
directories: {} }
(Note: I get the same as you with yarn, so I don't think it's an issue local to your machine.)
I think yarn use their own caching index in front of npm, so I suspect there's a caching issue with that.
Is it possible that Yarn's running some extra build checks that are failing?
Maybe you have an old yarn version?
I don't publish with yarn; I use npm publish. I do you yarn to install things though.
Could that be it? What happens if you publish it using the latest version of yarn?
Besides unpkg.com is on my side - that downloads the tarball and shows you the contents.
The weird thing is yarn info shows the correct dist-tags at the top. I've no idea where it's getting 0.9.3 from - I'm pretty sure it's a server-side cache for them.
Alright. I'll find a way around it for now and come back to it if it pops up again. Thank you for your time.
You know what? It's lexographic sorting, isn't it! 馃榿
Yarn is treating 0.9.3 as being larger than 0.11.1 because 9 comes after 1.
So much for "yarn FTW" 馃槈
(Seriously though, it's an impressive piece of tech - I use it daily.)
Looks like it's your prerelease tagging syntax that is deviating from semver and npm let you get away with it
alpha9.3 is "newer than" alpha11.2 -- instead you'd want alpha.9.3 and alpha.11.2
馃憤 I'll fix the versioning in the next release.
Thanks! How do I get release notifications? Will watching graphql-build be enough?
I'm currently using #506 to announce releases.