ecerroni / apollo-connector-kit Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://blog.mvp-space.com/authentication-and-authorization-boilerplate-with-apollo-2-0-b77042aba3f6
License: MIT License
Home Page: https://blog.mvp-space.com/authentication-and-authorization-boilerplate-with-apollo-2-0-b77042aba3f6
License: MIT License
Proxy error: Could not proxy request /graphql from localhost:3000 to graphql.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).
[HPM] Error occurred while trying to proxy request /graphql from localhost:3000 to http://localhost:3000 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
Using default app settings
{
"NAMESPACE": "connector",
"ENDPOINT": {
"PROTOCOL": "http",
"HOST": "localhost",
"PORT": 3000,
"GRAPHQL": "/graphql",
"GRAPHIQL": "/graphiql"
},
"CONSTANTS": {
"HTTP_ONLY": "HTTP_ONLY",
"LOCAL_STORAGE": "LOCAL_STORAGE",
"FORBIDDEN": "Forbidden",
"UNAUTHORIZED": "Unauthorized!"
},
"STRATEGIES": {
"HTTP_ONLY": true,
"LOCAL_STORAGE": true
},
"PREFIX": "x-",
"TOKEN_SUFFIX": "-token",
"REFRESH_TOKEN_SUFFIX": "-refresh-token",
"AUTH_HEADER_SUFFIX": "-auth-request-type"
}
I would like to add csrf token with every request sent to validate and respond only to authorized requests
Hi,
I am intrigued by your boilerplate and would like to customize it but I am running into the following errors during 'yarn install-all' step.
Win10 x64
VSCode
GitBash
node 10.15.3
yarn 1.16
npm 6.4.1
~/Desktop/apollo-boilerplate-test/apollo-connector-kit (master) yarn install-all
yarn run v1.16.0
$ yarn install && concurrently 'yarn:install-dev-*'
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
$ cd backend && yarn install
$ cd frontend-vue && yarn install
$ cd frontend-react && yarn install
warning package.json: No license field
[1/4] Resolving packages...
[1/4] Resolving packages...
warning [email protected]: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > [email protected]" has incorrect peer dependency "graphql@^0.9.0 || ^0.10.1 || ^0.11.0 || ^0.12.0 || ^0.13.0".
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > [email protected]" has incorrect peer dependency "graphql@^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0".
warning " > [email protected]" has unmet peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0".
warning " > [email protected]" has unmet peer dependency "eslint@^4.9.0".
warning "eslint-config-airbnb > [email protected]" has unmet peer dependency "eslint@^4.9.0".
warning " > [email protected]" has unmet peer dependency "eslint@>=3.14.1".
warning " > [email protected]" has unmet peer dependency "babel-eslint@^7.2.3".
warning " > [email protected]" has unmet peer dependency "eslint@^4.1.1".
warning " > [email protected]" has incorrect peer dependency "eslint-plugin-jsx-a11y@^5.1.1".
warning " > [email protected]" has unmet peer dependency "eslint@>=2.0.0".
warning " > [email protected]" has unmet peer dependency "[email protected] - 5.x".
warning " > [email protected]" has unmet peer dependency "eslint@^3 || ^4 || ^5".
warning postcss-preset-env > postcss-color-functional-notation > postcss-values-parser > [email protected]: I wrote this module a very long time ago; you sho
uld use something else.
[2/4] Fetching packages...
info [email protected]: The platform "win32" 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...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error C:\Users\Aervue\Desktop\apollo-boilerplate-test\apollo-connector-kit\backend\node_modules\bcrypt: Command failed.
[install-dev-apollo] Exit code: 1
[install-dev-apollo] Command: node-pre-gyp install --fallback-to-build
[install-dev-apollo] Arguments:
[install-dev-apollo] Directory: C:\Users\Aervue\Desktop\apollo-boilerplate-test\apollo-connector-kit\backend\node_modules\bcrypt
[install-dev-apollo] Output:
[install-dev-apollo] node-pre-gyp info it worked if it ends with ok
[install-dev-apollo] node-pre-gyp info using [email protected]
[install-dev-apollo] node-pre-gyp info using [email protected] | win32 | x64
[install-dev-apollo] node-pre-gyp WARN Using request for node-pre-gyp https download
[install-dev-apollo] node-pre-gyp info check checked for "C:\Users\Aervue\Desktop\apollo-boilerplate-test\apollo-connector-kit\backend\node_modules\bcryp
t\lib\binding\bcrypt_lib.node" (not found)
[install-dev-apollo] node-pre-gyp http GET https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.3/bcrypt_lib-v3.0.3-node-v64-win32-x64-unkno
wn.tar.gz
[install-dev-apollo] node-pre-gyp http 404 https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.3/bcrypt_lib-v3.0.3-node-v64-win32-x64-unkno
wn.tar.gz
[install-dev-apollo] node-pre-gyp WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.3/bcrypt_lib-v3.0.3-node
-v64-win32-x64-unknown.tar.gz
[install-dev-apollo] node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, unknown) (falling back to source com
pile with node-gyp)
[install-dev-apollo] node-pre-gyp http 404 status code downloading tarball https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.3/bcrypt_lib
-v3.0.3-node-v64-win32-x64-unknown.tar.gz
[install-dev-apollo]
[install-dev-apollo] C:\Users\Aervue\Desktop\apollo-boilerplate-test\apollo-connector-kit\backend\node_modules\bcrypt>if not defined npm_config_node_gyp
(node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean ) else (node "" clean )
[install-dev-apollo] gyp info it worked if it ends with ok
[install-dev-apollo] gyp info using [email protected]
[install-dev-apollo] gyp info using [email protected] | win32 | x64
[install-dev-apollo] gyp info ok
[install-dev-apollo]
[install-dev-apollo] C:\Users\Aervue\Desktop\apollo-boilerplate-test\apollo-connector-kit\backend\node_modules\bcrypt>if not defined npm_config_node_gyp
(node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=C:\
Users\Aervue\Desktop\apollo-boilerplate-test\apollo-connector-kit\backend\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --modu
le_path=C:\Users\Aervue\Desktop\apollo-boilerplate-test\apollo-connector-kit\backend\node_modules\bcrypt\lib\binding --napi_version=3 --node_abi_napi=nap
i --napi_build_version=0 --node_napi_label=node-v64 ) else (node "" configure --fallback-to-build --module=C:\Users\Aervue\Desktop\apollo-boilerplate-te
st\apollo-connector-kit\backend\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\Aervue\Desktop\apollo-boi
lerplate-test\apollo-connector-kit\backend\node_modules\bcrypt\lib\binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label
=node-v64 )
[install-dev-apollo] gyp info it worked if it ends with ok
[install-dev-apollo] gyp info using [email protected]
[install-dev-apollo] gyp info using [email protected] | win32 | x64
[install-dev-apollo] gyp ERR! configure error
[install-dev-apollo] gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
[install-dev-apollo] gyp ERR! stack at PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:484
:19)
[install-dev-apollo] gyp ERR! stack at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:509:
16)
[install-dev-apollo] gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
[install-dev-apollo] gyp ERR! stack at FSReqWrap.oncomplete (fs.js:153:21)
[install-dev-apollo] gyp ERR! System Windows_NT 10.0.18362
[install-dev-apollo] gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\n
ode-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Users\\Aervue\\Desktop\\apollo-boilerplate-test\\apollo-connector-kit\\backend\\node_modules\
\bcrypt\\lib\\binding\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\Users\\Aervue\\Desktop\\apollo-boilerplate-test\\apollo-connector-k
it\\backend\\node_modules\\bcrypt\\lib\\binding" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
[install-dev-apollo] gyp ERR! cwd C:\Users\Aervue\Desktop\apollo-boilerplate-test\apollo-connector-kit\backend\node_modules\bcrypt
[install-dev-apollo] gyp ERR! node -v v10.15.3
[install-dev-apollo] gyp ERR! node-gyp -v v3.8.0
[install-dev-apollo] gyp ERR! not ok
[install-dev-apollo] node-pre-gyp ERR! build error
[install-dev-apollo] node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\Aervue\Desktop\apollo
-boilerplate-test\apollo-connector-kit\backend\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\Aervue\Des
ktop\apollo-boilerplate-test\apollo-connector-kit\backend\node_modules\bcrypt\lib\binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --
node_napi_label=node-v64' (1)
[install-dev-apollo] node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\Aervue\Desktop\apollo-boilerplate-test\apollo-connector-kit\backen
d\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
[install-dev-apollo] node-pre-gyp ERR! stack at ChildProcess.emit (events.js:189:13)
[install-dev-apollo] node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:970:16)
[install-dev-apollo] node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
[install-dev-apollo] node-pre-gyp ERR! System Windows_NT 10.0.18362
[install-dev-apollo] node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Aervue\\Desktop\\apollo-boilerplate-test\\apollo-connect
or-kit\\backend\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
[install-dev-apollo] node-pre-gyp ERR! cwd C:\Users\Aervue\Desktop\apollo-boilerplate-test\apollo-connector-kit\backend\node_modules\bcrypt
[install-dev-apollo] node-pre-gyp ERR! node -v v10.15.3
[install-dev-apollo] node-pre-gyp ERR! node-pre-gyp -v v0.12.0
[install-dev-apollo] node-pre-gyp ERR! not ok
[install-dev-apollo] Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\Aervue\Desktop\apollo-boilerplate-test\apollo-connec
tor-kit\backend\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\Aervue\Desktop\apollo-boilerplate-test\ap
ollo-connector-kit\backend\node_modules\bcrypt\lib\binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
[install-dev-apollo] yarn run install-dev-apollo exited with code 1
[4/4] Building fresh packages...
[4/4] Building fresh packages...
success Saved lockfile.
[install-dev-vue] yarn run install-dev-vue exited with code 0
$ ln -sfn $(dirname $(pwd))/settings './src/settings'
[install-dev-react] ln: target './src/settings' is not a directory
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[install-dev-react] error Command failed with exit code 1.
[install-dev-react] yarn run install-dev-react exited with code 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Hi any plan to upgrade to apollo-server version 2?
Although it works perfectly on the local where it is used the first time it does not propagate when it is share between more than one developers after pulling it from the git repo.
Scenario:
Dev#1 use the script and builds a graphql component. Finally it pushes the changes to master
Dev#2 pulls from master. Although he see the new component folder and all files in it, the client query will always return undefined.
Possible cause:
It could be a problem with cache. Either babel loader or the wildcard import plugin we're using
Although the client receive either an error or a null response the operation is still executed on the server.
This works for queries, but not for mutations. Indeed once the client refreshes the data has been mutated anyway.
To fix it move constraints' validation checks before query execution.
Hi, I am using serverless and it gives me problems to modify the token in the header.
Serverless delivers the event to the context
Great job with this project ;)
I've tried running the React dev server and Apollo server using default settings. On login with the admin user, the server throws an Unautorized!
error when I login successfully via the username/password login. Is this expected behavior?
Error clearly originates from authenticated (resolver) higher order function
const authenticated = resolver => (parent, args, context, info) => {
// console.log('context user', context.user);
if (context.user) {
return resolver(parent, args, context, info);
}
console.log('resolver:authenticated')
throw new Error(UNAUTHORIZED); // this is gonna be handled in _format-errors
};
https://zach.codes/handling-auth-in-graphql-the-right-way/
On login with limited access user kris
, I get 403: Forbidden (which makes sense)
It is also a bit unclear how to configure the app to use a cookie auth strategy. I can see in my Chrome Dev Tools, that the localstorage is set with two entries and that if I delete them, I'm asked to login again, however I don't see any cookies being set.
I tried to log cookies used on server side in handleAuthentication
if (httpOnly) {
token = getCookie(req.headers.cookie, JWT.COOKIE.TOKEN.NAME);
refreshToken = getCookie(req.headers.cookie, JWT.COOKIE.REFRESH_TOKEN.NAME);
console.log('cookies', {
token,
refreshToken
})
}
From the code it looks like it parses the strategies part of the app config and if httpOnly is set, it will get (and later potentially set) the cookies, however it seems to throw before it gets there...
"STRATEGIES": {
"HTTP_ONLY": true,
"LOCAL_STORAGE": true
},
Please advice.
In our setup we would like to use cookies and we have a React app on one domain/port talking to a GraphQL server on another domain/port which talks to our API gateway. How do we best pass on the cookie info? I see by default you have a Cors same origin
configuration. Assume we need to use include
as outlined in Apollo auth cookie docs
Thanks for an excellent project. Hope we can use it in our project to minimize setup/config effort.
Cheers!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.