Code Monkey home page Code Monkey logo

examples's Introduction

PostGraphile Examples

๐ŸšจTemporarily unmaintained๐Ÿšจ This repo is currently not maintained and is out of date - Please make sure that you update the dependancies in your copy of these examples. For an up to date example, see the Graphile Starter. We rely on sponsorship from the Graphile community to continue our work in Open Source. By donating to our GitHub Sponsors or Patreon fund, you'll help us spend more time on Open Source, and this repo will be updated quicker. Thank you to all our sponsors ๐Ÿ™Œ

This repository will contain examples of using PostGraphile with different servers and clients.

To get started:

npm install -g yarn
yarn
./setup.sh
# Now add GITHUB_KEY and GITHUB_SECRET to .env (see "Login via GitHub" below)
yarn start

This will run the koa2 server and react client. You can access it at http://localhost:8349/

It's recommended that you review the setup.sh script before executing it.

The first user account to log in will automatically be made an administrator.

Login via GitHub

To use social login you will need to create a GitHub application. This takes just a few seconds:

  1. Visit https://github.com/settings/applications/new
  2. Enter name: GraphileDemo
  3. Enter homepage URL: http://localhost:8349
  4. Enter authorization callback URL: http://localhost:8349/auth/github/callback
  5. Press "Register Application"
  6. Copy the 'Client ID' and 'Client Secret' into GITHUB_KEY and GITHUB_SECRET respectively in the .env file that was created by setup.sh

Koa2

Koa 2 only has "experimental" support in PostGraphile officially, but if you face any issues please file them against PostGraphile with full reproduction instructions - we're trying to elevate Koa to full support status.

examples's People

Contributors

bdombro avatar benjie avatar commanderroot avatar connorholyday avatar dependabot[bot] avatar jemgillam avatar kalepail avatar mattbretl avatar singingwolfboy avatar snyk-bot avatar wanradt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

examples's Issues

Setup script missing plv8 extension

Running the ./setup.sh script results in this:

ERROR:  could not open extension control file "/usr/local/share/postgresql/extension/plv8.control": No such file or directory

Is this what I need to setup?

PostgreSQL registration/login fails

When I use this repo, all registrations and some logins fails, without any postgres errors. In /shared/plugins/PassportLoginPlugin.js all sql query of

          const {
            rows: [user],
          } = await rootPgPool.query(
            `select users.* from app_private.really_create_user(
              username => $1,
              email => $2,
              email_is_verified => false,
              name => $3,
              avatar_url => $4,
              password => $5
            ) users where users is not null`,
            [username, email, name, avatarUrl, password]
          );

and

          const {
            rows: [user],
          } = await rootPgPool.query(
            `select users.* from app_private.login($1, $2) users where users is not null`,
            [username, password]
          );

Always return user as undefined.
Problem in this row users where users is not null, in PostgreSQL expression users is not null and not (users is null) not equal. When some field in users is null expression users is not null return false, so this query will not return user even when query successful.


PostgreSQL documentation quote:

If the expression is row-valued, then IS NULL is true when the row expression itself is null or when all the row's fields are null, while IS NOT NULL is true when the row expression itself is non-null and all the row's fields are non-null.

Addition information you can find in this question

Use 127.0.0.1 for brew

This took some time to debug, so hopefully it will help those who prefer to manage postresql with homebrew for a fast installation.

Installing postgresql:

brew install postgresql
brew services start postgresql
git clone https://github.com/graphile/examples.git
cd examples
yarn
./setup.sh

The setup.sh will fail to connect to the database to initialize the database schema unless "localhost" is replaced with the IP "127.0.0.1"

There appears to be some issue with mapping localhost which may be related to the homebrew postgres install.

license

been reading through this and wanted to possibly contribute, but just noticed there is no license. Are there plans to add one?

Authenticator vs Visitor

If I'm understanding the explanation correctly, a query by a non-verified user will be as an "Authenticator." And once the user logs in/gets verified, then the queries will be ran as a "Visitor." Could someone verify this is the correct understanding?

The term "Authenticator" to describe an anonymous initial non-verified user seems incorrect; The title "Authenticator" deceivingly sounds like a role with a higher permission/privilege than a "Visitor". A non-verified user should really be an authenticatee as he/she will be the one getting authenticated and not doing the actual action of authenticating others. ("visitor" fits the unverified user better than the current Visitor...)

It took me all day to realize the above... I think the better terms would be: "Unauthenticated/Anonymous/Unverified" vs "Authorized/AuthorizedUser/Verified/VerifiedUser/Authenticated" or something along that line, which shows a clear distinction between the two roles.

Yarn start is failing

What am I missing gents?

$ yarn start
yarn run v1.13.0
$ concurrently --kill-others 'npm run server:koa2' 'npm run client:react'
[0] npm WARN lifecycle The node binary used for scripts is /var/folders/xn/mv_kd6_s3f572s7m_q8pt7580000gn/T/yarn--1551453787248-0.06708648276839879/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
[0] 
[0] > @ server:koa2 /Users/tyler/Desktop/examples
[0] > cd server-koa2; npm start
[0] 
[1] npm WARN lifecycle The node binary used for scripts is /var/folders/xn/mv_kd6_s3f572s7m_q8pt7580000gn/T/yarn--1551453787248-0.06708648276839879/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
[1] 
[1] > @ client:react /Users/tyler/Desktop/examples
[1] > cd client-react; npm start
[1] 
[0] npm WARN lifecycle The node binary used for scripts is /var/folders/xn/mv_kd6_s3f572s7m_q8pt7580000gn/T/yarn--1551453787248-0.06708648276839879/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
[0] 
[0] > [email protected] start /Users/tyler/Desktop/examples/server-koa2
[0] > if [ -x ../.env ]; then . ../.env; fi; NODE_ENV=development nodemon server.js
[0] 
[1] npm WARN lifecycle The node binary used for scripts is /var/folders/xn/mv_kd6_s3f572s7m_q8pt7580000gn/T/yarn--1551453787248-0.06708648276839879/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
[1] 
[1] > [email protected] start /Users/tyler/Desktop/examples/client-react
[1] > if [ -x ../.env ]; then . ../.env; fi; BROWSER=none PORT=$CLIENT_PORT react-scripts start
[1] 
[1] 
[1] There might be a problem with the project dependency tree.
[1] It is likely not a bug in Create React App, but something you need to fix locally.
[1] 
[1] The react-scripts package provided by Create React App requires a dependency:
[1] 
[1]   "babel-eslint": "9.0.0"
[1] 
[1] Don't try to install it manually: your package manager does it automatically.
[1] However, a different version of babel-eslint was detected higher up in the tree:
[1] 
[1]   /Users/tyler/Desktop/examples/node_modules/babel-eslint (version: 8.2.5) 
[1] 
[1] Manually installing incompatible versions is known to cause hard-to-debug issues.
[1] 
[1] If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
[1] That will permanently disable this message but you might encounter other issues.
[1] 
[1] To fix the dependency tree, try following the steps below in the exact order:
[1] 
[1]   1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
[1]   2. Delete node_modules in your project folder.
[1]   3. Remove "babel-eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
[1]   4. Run npm install or yarn, depending on the package manager you use.
[1] 
[1] In most cases, this should be enough to fix the problem.
[1] If this has not helped, there are a few other things you can try:
[1] 
[1]   5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
[1]      This may help because npm has known issues with package hoisting which may get resolved in future versions.
[1] 
[1]   6. Check if /Users/tyler/Desktop/examples/node_modules/babel-eslint is outside your project directory.
[1]      For example, you might have accidentally installed something in your home folder.
[1] 
[1]   7. Try running npm ls babel-eslint in your project folder.
[1]      This will tell you which other package (apart from the expected react-scripts) installed babel-eslint.
[1] 
[1] If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
[1] That would permanently disable this preflight check in case you want to proceed anyway.
[1] 
[1] P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
[1] 
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1
[1] npm ERR! [email protected] start: `if [ -x ../.env ]; then . ../.env; fi; BROWSER=none PORT=$CLIENT_PORT react-scripts start`
[1] npm ERR! Exit status 1
[1] npm ERR! 
[1] npm ERR! Failed at the [email protected] start script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1] 
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR!     /Users/tyler/.npm/_logs/2019-03-01T15_23_08_817Z-debug.log
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1
[1] npm ERR! @ client:react: `cd client-react; npm start`
[1] npm ERR! Exit status 1
[1] npm ERR! 
[1] npm ERR! Failed at the @ client:react script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1] 
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR!     /Users/tyler/.npm/_logs/2019-03-01T15_23_08_845Z-debug.log
[1] npm run client:react exited with code 1
--> Sending SIGTERM to other processes..
[0] [nodemon] 1.17.5
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching: *.*
[0] [nodemon] starting `node server.js`
[0] npm run server:koa2 exited with code null
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Haven't edit or changed anything, just pulled, built and tried to run.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.