{"id":47884,"library":"graphql-introspection-filtering","title":"graphql-introspection-filtering","description":"GraphQL library to filter introspection query results by hiding restricted fields and types using schema mappers and directives. Current stable version: 3.0.0. Maintained actively, tested with GraphQL 16.6.0 and @graphql-tools 8.0.0-10.0.0. Key differentiator: allows conditional filtering based on context, supports skipping unfiltered queries, and integrates with makeExecutableSchema. Requires peer dependencies graphql >=14.0.0, @graphql-tools/schema >=8.0.0, and @graphql-tools/utils >=8.0.0. Ships TypeScript type definitions.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/vertexbz/graphql-introspection-filtering","tags":["javascript","graphql","schema","introspection","filtering","filter","directive","typescript"],"install":[{"cmd":"npm install graphql-introspection-filtering","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-introspection-filtering","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-introspection-filtering","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for GraphQL schema and introspection types","package":"graphql","optional":false},{"reason":"Peer dependency for makeExecutableSchema and schema manipulation","package":"@graphql-tools/schema","optional":false},{"reason":"Peer dependency for GraphQL utilities, e.g., mapSchema","package":"@graphql-tools/utils","optional":false}],"imports":[{"note":"The package re-exports and extends makeExecutableSchema from @graphql-tools/schema with introspection filtering support.","wrong":"import { makeExecutableSchema } from '@graphql-tools/schema'","symbol":"makeExecutableSchema","correct":"import { makeExecutableSchema } from 'graphql-introspection-filtering'"},{"note":"This mapSchema is the introspection-aware version that applies the mapper to filter introspection results.","wrong":"import { mapSchema } from '@graphql-tools/utils'","symbol":"mapSchema","correct":"import { mapSchema } from 'graphql-introspection-filtering'"},{"note":"Enum used to define mapper keys for different schema types. No CommonJS export for this symbol.","symbol":"IntrospectionMapperKind","correct":"import { IntrospectionMapperKind } from 'graphql-introspection-filtering'"}],"quickstart":{"code":"import { makeExecutableSchema, mapSchema, IntrospectionMapperKind } from 'graphql-introspection-filtering';\n\nconst typeDefs = `\n  directive @restricted on OBJECT | FIELD_DEFINITION\n\n  type Query {\n    publicField: String\n    secretField: String @restricted\n  }\n`;\n\nconst resolvers = {\n  Query: {\n    publicField: () => 'public',\n    secretField: () => 'secret',\n  },\n};\n\nconst mapper = {\n  [IntrospectionMapperKind.OBJECT_TYPE](result, parent, schema) {\n    if (result.astNode?.directives?.some(d => d.name.value === 'restricted')) {\n      return null;\n    }\n    return result;\n  },\n  [IntrospectionMapperKind.FIELD](result, parent, schema) {\n    if (result.astNode?.directives?.some(d => d.name.value === 'restricted')) {\n      return null;\n    }\n    return result;\n  },\n};\n\nconst schema = makeExecutableSchema({ typeDefs, resolvers });\nconst filteredSchema = mapSchema(schema, mapper);\n\nconsole.log(filteredSchema);","lang":"typescript","description":"Creates a GraphQL schema with a @restricted directive and filters introspection to hide restricted fields and types."},"warnings":[{"fix":"Ensure that all types referenced by visible fields are also visible, or provide stub types.","message":"Missing dependent types cause introspection failure: if a type is filtered out but referenced by a visible field, the client cannot rebuild the schema.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add a Query type with at least one field to your schema definition.","message":"Query type must be defined in the schema, otherwise filtering will not work.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure each visible object type has at least one field that is not filtered out.","message":"Object types must contain at least one visible field; if all fields are filtered, the type will cause introspection errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to @graphql-tools/schema >=8.0.0 or pin graphql-introspection-filtering to version 2.1.0.","message":"Legacy graphql-tools versions before 8.0.0 are no longer supported. Use release 2.1.0 for older graphql-tools.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"search_vec":"'/schema':63 '/utils':69 '10.0.0':38 '14.0.0':59 '16.6.0':32 '3.0.0':26 '8.0.0':37,64,70 'activ':28 'allow':41 'base':44 'condit':42 'context':46 'current':23 'definit':74 'depend':57 'differenti':40 'direct':22,81 'field':15 'filter':4,8,43,79,80 'graphql':2,5,31,35,58,61,67,76 'graphql-introspection-filt':1 'graphql-tool':34,60,66 'hide':13 'integr':52 'introspect':3,9,78 'javascript':75 'key':39 'librari':6 'maintain':27 'makeexecutableschema':54 'mapper':20 'peer':56 'queri':10,50 'requir':55 'restrict':14 'result':11 'schema':19,77 'ship':71 'skip':48 'stabl':24 'support':47 'test':29 'tool':36,62,68 'type':17,73 'typescript':72,82 'unfilt':49 'use':18 'version':25","created_at":"2026-06-07T16:53:49.038653+00:00","updated_at":"2026-06-07T16:53:49.038653+00:00","problems":[{"fix":"Ensure only one version of graphql is installed using npm dedupe or yarn resolutions.","cause":"Multiple instances of graphql package in node_modules causing type mismatch.","error":"Error: Cannot use GraphQLSchema \"[object Object]\" from another module or realm."},{"fix":"Add the missing mapper kind function, at least for FIELD if not all types.","cause":"Mapper object does not include all required keys (e.g., FIELD).","error":"TypeError: mapper[IntrospectionMapperKind.OBJECT_TYPE] is not a function"},{"fix":"Add 'type Query { dummy: String }' to your typeDefs.","cause":"Schema definition does not include a Query type.","error":"Error: Query root type must be provided."}],"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/vertexbz/graphql-introspection-filtering#readme","github":"https://github.com/vertexbz/graphql-introspection-filtering","docs":null,"changelog":null,"pypi":null,"npm":"graphql-introspection-filtering","openapi_spec":null,"status_page":null,"smithery":null,"categories":["security"],"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}}