{"id":16858454,"url":"https://github.com/andimarek/graphql-analyzer","last_synced_at":"2025-03-22T06:31:17.514Z","repository":{"id":46927768,"uuid":"195626479","full_name":"andimarek/graphql-analyzer","owner":"andimarek","description":"Static analysis of GraphQL queries","archived":false,"fork":false,"pushed_at":"2023-01-04T03:55:07.000Z","size":589,"stargazers_count":15,"open_issues_count":13,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T09:02:32.054Z","etag":null,"topics":["graphql"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andimarek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-07T08:13:43.000Z","updated_at":"2024-03-28T02:05:37.000Z","dependencies_parsed_at":"2023-02-01T19:30:50.281Z","dependency_job_id":null,"html_url":"https://github.com/andimarek/graphql-analyzer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andimarek%2Fgraphql-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andimarek%2Fgraphql-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andimarek%2Fgraphql-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andimarek%2Fgraphql-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andimarek","download_url":"https://codeload.github.com/andimarek/graphql-analyzer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244918500,"owners_count":20531682,"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":["graphql"],"created_at":"2024-10-13T14:13:05.680Z","updated_at":"2025-03-22T06:31:15.435Z","avatar_url":"https://github.com/andimarek.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphQL analyzer\n\nStatic analysis of GraphQL queries (analysis without actually executing the query).\n\nPlease see this blog post for background and details: [Static analysis of GraphQL queries\n](https://www.graphql.de/blog/static-query-analysis/)\n\n# Usage\n\nAdd to your project:\n\n```sh\nnpm install graphql-analyzer\n```\n\n`graphql-analyzer` exports three functions:\n\n```typescript\nimport {analyzeQuery, printDependencyGraph, traverseFieldVertices } from 'graphql-analyzer';\n```\n\n`analyseQuery` returns a the root `FieldVertex` of the dependency graph.\n\nDetails:\n```typescript\nexport interface FieldVertex {\n    id: string;\n    fields: Array\u003cFieldNode\u003e;\n    objectType: GraphQLObjectType;\n    fieldDefinition: GraphQLField\u003cany, any\u003e;\n    dependsOn: Array\u003cFieldVertex\u003e;\n    dependOnMe: Array\u003cFieldVertex\u003e;\n}\nexport function analyzeQuery(\n    document: DocumentNode, \n    schema: GraphQLSchema, \n    rawVariableValues?: { [key: string]: any; }, \n    validateQuery?: boolean)\n    : FieldVertex;\n```\n\n`printDependencyGraph` returns all vertices and all edges for a dependency graph:\n\n```typescript\nexport interface DependencyEdge {\n    from: FieldVertex;\n    to: FieldVertex;\n    conditional: boolean;\n}\nexport function printDependencyGraph(\n    root: FieldVertex)\n    : [Array\u003cFieldVertex\u003e, Array\u003cDependencyEdge\u003e];\n```\n\n`traverseFieldVertices` lets you traverse the graph returned by `analyzeQuery`:\n\n```typescript\nexport function traverseFieldVertices(\n    root: FieldVertex, \n    visitor: (vertex: FieldVertex) =\u003e void)\n    : void;\n```\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandimarek%2Fgraphql-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandimarek%2Fgraphql-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandimarek%2Fgraphql-analyzer/lists"}