{"id":27146234,"url":"https://github.com/ryands17/nexus-auth","last_synced_at":"2025-04-08T10:09:55.961Z","repository":{"id":39617893,"uuid":"202205163","full_name":"ryands17/nexus-auth","owner":"ryands17","description":"A sample auth module with Prisma 2 and Nexus","archived":false,"fork":false,"pushed_at":"2024-05-21T23:18:22.000Z","size":3084,"stargazers_count":159,"open_issues_count":11,"forks_count":19,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-22T00:27:17.282Z","etag":null,"topics":["nexus","node","prisma2","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryands17.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-13T18:44:44.000Z","updated_at":"2024-05-22T00:27:20.364Z","dependencies_parsed_at":"2023-02-13T19:02:16.664Z","dependency_job_id":"c47d0059-e0ba-450b-8530-88c2b77b78ab","html_url":"https://github.com/ryands17/nexus-auth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryands17%2Fnexus-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryands17%2Fnexus-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryands17%2Fnexus-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryands17%2Fnexus-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryands17","download_url":"https://codeload.github.com/ryands17/nexus-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247819947,"owners_count":21001394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nexus","node","prisma2","typescript"],"created_at":"2025-04-08T10:09:54.933Z","updated_at":"2025-04-08T10:09:55.929Z","avatar_url":"https://github.com/ryands17.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphQL Server with Authentication Prisma 2 and Nexus Schema\n\n![Build Status](https://github.com/ryands17/nexus-auth/workflows/CI/badge.svg)\n\nThis example shows how to implement a **GraphQL server with an email-password-based auth**, based on [Prisma](https://www.prisma.io/), [apollo-server](https://www.apollographql.com/server/), [graphql-shield](https://github.com/maticzav/graphql-shield) \u0026 [Nexus Schema](https://www.nexusjs.org/#/components/schema/about) via the [Nexus Prisma](https://www.nexusjs.org/#/components/schema/plugins/prisma) plugin.\n\n## How to use\n\n### 1. Clone this repo \u0026 install dependencies\n\nInstall Node dependencies:\n\n`yarn` (recommended) or `npm install`\n\n### 2. Set up the database\n\nThis uses a simple [SQLite database](https://www.sqlite.org/index.html).\n\n**_Note_**: You can delete the migrations folder to create your own new migrations\n\nTo set up your database, run:\n\n```sh\nyarn db:save\nyarn db:migrate\n```\n\nYou can now use the [SQLite Browser](https://sqlitebrowser.org/) to view and edit your data in the `./prisma/dev.db` file that was created when you ran `yarn db:migrate`.\n\n### 3. Generate Prisma Client (type-safe database client)\n\nRun the following command to generate [Prisma Client](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/generating-prisma-client):\n\n```sh\nyarn generate:prisma\n```\n\nNow you can seed your database using the `seed` script from `package.json`:\n\n```sh\nyarn seed\n```\n\n### 4. Start the GraphQL server\n\nLaunch your GraphQL server with this command:\n\n```sh\nyarn dev\n```\n\nNavigate to [http://localhost:4002](http://localhost:4002) in your browser to explore the API of your GraphQL server in a [GraphQL Playground](https://github.com/prisma-labs/graphql-playground).\n\n### 5. Using the GraphQL API\n\nThe schema that specifies the API operations of your GraphQL server is defined in [`./src/generated/schema.graphql`](./src/generated/schema.graphql). Below are a number of operations that you can send to the API using the GraphQL Playground.\n\nFeel free to adjust any operation by adding or removing fields. The GraphQL Playground helps you with its auto-completion and query validation features.\n\n#### Retrieve all published posts and their authors\n\n```graphql\nquery {\n  feed {\n    id\n    title\n    content\n    published\n    author {\n      id\n      name\n      email\n    }\n  }\n}\n```\n\n\u003cDetails\u003e\u003cSummary\u003e\u003cstrong\u003eSee more API operations\u003c/strong\u003e\u003c/Summary\u003e\n\n#### Register a new user\n\nYou can send the following mutation in the Playground to sign up a new user and retrieve an authentication token for them:\n\n```graphql\nmutation {\n  signup(name: \"Alice\", email: \"alice@prisma.io\", password: \"graphql\") {\n    token\n  }\n}\n```\n\n#### Log in an existing user\n\nThis mutation will log in an existing user by requesting a new authentication token for them:\n\n```graphql\nmutation {\n  login(email: \"alice@prisma.io\", password: \"graphql\") {\n    token\n  }\n}\n```\n\n#### Check whether a user is currently logged in with the `me` query\n\nFor this query, you need to make sure a valid authentication token is sent along with the `Bearer`-prefix in the `Authorization` header of the request:\n\n```json\n{\n  \"Authorization\": \"Bearer __YOUR_TOKEN__\"\n}\n```\n\nWith a real token, this looks similar to this:\n\n```json\n{\n  \"Authorization\": \"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjanAydHJyczFmczE1MGEwM3kxaWl6c285IiwiaWF0IjoxNTQzNTA5NjY1fQ.Vx6ad6DuXA0FSQVyaIngOHYVzjKwbwq45flQslnqX04\"\n}\n```\n\nInside the Playground, you can set HTTP headers in the bottom-left corner:\n\nOnce you've set the header, you can send the following query to check whether the token is valid:\n\n```graphql\n{\n  me {\n    id\n    name\n    email\n  }\n}\n```\n\n\u003c/Details\u003e\n\n### 6. Changing the GraphQL schema\n\nTo make changes to the GraphQL schema, you need to manipulate the files in the resolvers folder.\n\n## Next steps\n\n### Testing\n\nRun `yarn test` or `npm run test` to run tests via Jest in the **tests** folder.\n\n- Check out the [Prisma docs](https://www.prisma.io/docs/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryands17%2Fnexus-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryands17%2Fnexus-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryands17%2Fnexus-auth/lists"}