{"id":16367961,"url":"https://github.com/ephys/graphql-non-null-directive","last_synced_at":"2025-10-16T16:03:13.453Z","repository":{"id":57111781,"uuid":"380475202","full_name":"ephys/graphql-non-null-directive","owner":"ephys","description":"Allow an input to be undefined, but not null (useful for partial update mutations)","archived":false,"fork":false,"pushed_at":"2022-01-19T15:18:25.000Z","size":84,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-07T16:02:13.061Z","etag":null,"topics":[],"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/ephys.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}},"created_at":"2021-06-26T10:30:24.000Z","updated_at":"2023-06-06T12:55:34.000Z","dependencies_parsed_at":"2022-08-21T10:31:01.586Z","dependency_job_id":null,"html_url":"https://github.com/ephys/graphql-non-null-directive","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ephys/graphql-non-null-directive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ephys%2Fgraphql-non-null-directive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ephys%2Fgraphql-non-null-directive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ephys%2Fgraphql-non-null-directive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ephys%2Fgraphql-non-null-directive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ephys","download_url":"https://codeload.github.com/ephys/graphql-non-null-directive/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ephys%2Fgraphql-non-null-directive/sbom","scorecard":{"id":378969,"data":{"date":"2025-08-11","repo":{"name":"github.com/ephys/graphql-non-null-directive","commit":"e856252c47f037197710d96a6900eb1e62376a92"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/11 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"18 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-7gc6-qh9x-w6h8","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T14:57:05.866Z","repository_id":57111781,"created_at":"2025-08-18T14:57:05.867Z","updated_at":"2025-08-18T14:57:05.867Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274005337,"owners_count":25205934,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-11T02:51:17.380Z","updated_at":"2025-10-16T16:03:13.341Z","avatar_url":"https://github.com/ephys.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphql-non-null-directive\n\nMakes your GraphQL input optional, but not null!\n\n## The problem\n\n[GraphQL Thread from 2018](https://github.com/graphql/graphql-spec/issues/542)\n\nIt's common for Update mutations to accept a partial input, in order to do a partial update.\n\nThe simplest version of this is to simply omit the non-nullish (`!`) operator in the input declaration, and not update anything that's nullish:\n\n```graphql\ninput UpdateUserInput {\n  firstName: String\n  lastName: String\n  country: String\n  # ...\n}\n```\n\nThe issue with this is that you lose the ability to say \"if provided, this field cannot be null\"\n\nWith a `@nonNull` directive, you get this ability back:\n\n```graphql\ninput UpdateUserInput {\n  firstName: String @nonNull\n  lastName: String @nonNull\n  country: String\n  # ...\n}\n```\n\n### Caveats\n\nThe `@nonNull` directive cannot be used on Argument Definitions. \nThat is because, unlike in Object Inputs, GraphQL.js will always default optional arguments to `null`.\n\nInstead of:\n\n```graphql\n# this does not work!\ntype Mutation {\n  updateUser(firstName: String @nonNull): User\n}\n```\n\nDo:\n\n```graphql\n# this works!\ntype Mutation {\n  updateUser(input: UpdateUserInput!): User\n}\n\ninput UpdateUserInput {\n  firstName: String @nonNull\n  # ...\n}\n```\n\n## Usage\n\n**NB: This library is built using graphql-tools and should be compatible with apollo*\n\n- Install from npm: [`npm i @ephys/graphql-non-null-directive`](https://www.npmjs.com/package/@ephys/graphql-non-null-directive)\n- Declare the directive in your schema: \n    ```graphql\n    directive @nonNull on INPUT_FIELD_DEFINITION\n    ```\n- Declare the directive in your Apollo Server:\n    ```typescript\n    import { createNonNullDirective } from '@ephys/graphql-non-null-directive';\n  \n    const server = new ApolloServer({\n      // ...\n      schemaDirectives: { \n        nonNull: createNonNullDirective({\n          // (optional) use this property to change the ID of the directive\n          directiveName: 'nonNull',\n          // (optional) use this property to configure how Input Errors are built\n          //  Input Errors are thrown when a @nonNull input received null..\n          buildInputError: (message: string) =\u003e {\n            return new Error(message);\n          },\n        }),\n      },\n    });\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fephys%2Fgraphql-non-null-directive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fephys%2Fgraphql-non-null-directive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fephys%2Fgraphql-non-null-directive/lists"}