{"id":47943,"library":"graphql-sock","title":"graphql-sock - Semantic Nullability Converter","description":"GraphQL SOCK converts SDL files that use semantic nullability (via @semanticNonNull directive or GraphQLSemanticNonNull wrapper) into traditional SDL for legacy tooling. Version 1.0.1 is the current stable release. It supports two modes: 'semantic-to-nullable' strips semantic non-null markers, while 'semantic-to-strict' replaces them with strict non-null. The library works as a CLI tool or programmatic API. Requires graphql 15.x, 16.x, or 17.x as a peer dependency. Differentiates from similar tools by supporting both the directive and the experimental asterisk syntax, with fine-grained level control for nested types.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https+git://github.com/graphile/graphql-sock","tags":["javascript","graphql","throw","error","errors","raise","exception","semantic","null","typescript"],"install":[{"cmd":"npm install graphql-sock","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-sock","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-sock","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only; CommonJS require will fail.","wrong":"const sock = require('graphql-sock')","symbol":"default","correct":"import { sock } from 'graphql-sock'"},{"note":"sock is a named export, not a default export.","wrong":"import sock from 'graphql-sock'","symbol":"sock","correct":"import { sock } from 'graphql-sock'"},{"note":"Use type-only import for type safety and to avoid bundling issues.","wrong":"import { SockOptions } from 'graphql-sock'","symbol":"TypeScript type","correct":"import type { SockOptions } from 'graphql-sock'"}],"quickstart":{"code":"import { sock } from 'graphql-sock';\nimport { buildSchema, printSchema } from 'graphql';\n\nconst sdl = `\n  type Query {\n    user: User @semanticNonNull\n    users: [User] @semanticNonNull(levels: [0, 1])\n  }\n  type User {\n    id: ID!\n    name: String\n  }\n`;\n\nconst schema = buildSchema(sdl);\n\nconst newSdl = sock(schema, { mode: 'semantic-to-strict' });\nconsole.log(printSchema(newSdl));\n// Output: user is now User! and users is [User!]!","lang":"typescript","description":"Converts a GraphQL schema with semantic nullability to strict non-null markers using the programmatic API."},"warnings":[{"fix":"Use import syntax or switch to dynamic import().","message":"ESM-only package; CommonJS require will throw ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Install a compatible version of graphql: npm install graphql@^16.0.0","message":"The 'graphql' peer dependency must be 15.x, 16.x, or 17.x. Using 14.x or 18.x may cause runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Migrate to the GraphQLSemanticNonNull wrapper type when available in your GraphQL.js version.","message":"The @semanticNonNull directive is a temporary placeholder and may be removed in future spec versions.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Install graphql@canary-pr-4192 or convert asterisk syntax to @semanticNonNull directive before using sock.","message":"Input SDL with asterisk syntax requires a patched version of graphql (graphql@canary-pr-4192) for proper parsing.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use printSchema(result) from the 'graphql' package to obtain the SDL string.","message":"The function returns a GraphQLSchema object, not SDL string. To get SDL, use printSchema from graphql.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.1':29 '15':73 '16':75 '17':78 'api':70 'asterisk':96 'cli':66 'control':103 'convert':6,9 'current':32 'depend':83 'differenti':84 'direct':18,92 'error':110,111 'except':113 'experiment':95 'file':11 'fine':100 'fine-grain':99 'grain':101 'graphql':2,7,72,108 'graphql-sock':1 'graphqlsemanticnonnul':20 'javascript':107 'legaci':26 'level':102 'librari':62 'marker':48 'mode':38 'nest':105 'non':46,59 'non-nul':45,58 'null':47,60,115 'nullabl':5,15,42 'peer':82 'programmat':69 'rais':112 'releas':34 'replac':54 'requir':71 'sdl':10,24 'semant':4,14,40,44,51,114 'semantic-to-nul':39 'semantic-to-strict':50 'semanticnonnul':17 'similar':86 'sock':3,8 'stabl':33 'strict':53,57 'strip':43 'support':36,89 'syntax':97 'throw':109 'tool':27,67,87 'tradit':23 'two':37 'type':106 'typescript':116 'use':13 'version':28 'via':16 'work':63 'wrapper':21 'x':74,76,79","created_at":"2026-06-07T16:54:07.602449+00:00","updated_at":"2026-06-07T16:54:07.602449+00:00","problems":[{"fix":"Replace require with import or use dynamic import().","cause":"Using require() to load an ES module.","error":"ERR_REQUIRE_ESM"},{"fix":"Run npm install graphql@^16.0.0","cause":"Missing graphql peer dependency.","error":"Cannot find module 'graphql'"},{"fix":"Check GraphQL version; ensure it's 15, 16, or 17.","cause":"Using a graphql version outside supported range (15.x, 16.x, 17.x).","error":"TypeError: Cannot read properties of undefined (reading 'astNode')"},{"fix":"Install graphql@canary-pr-4192 or replace * with @semanticNonNull directive.","cause":"Asterisk syntax for semantic nullability not supported by installed graphql version.","error":"Syntax Error: Expected Name, found '*'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/graphile/graphql-sock","github":"https+git://github.com/graphile/graphql-sock","docs":null,"changelog":null,"pypi":null,"npm":"graphql-sock","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}