{"id":20111925,"url":"https://github.com/graphpql/graphpinator-where-directives","last_synced_at":"2025-05-06T11:31:26.911Z","repository":{"id":50094657,"uuid":"336770172","full_name":"graphpql/graphpinator-where-directives","owner":"graphpql","description":":zap::globe_with_meridians::zap: Executable directives to filter values in lists.","archived":false,"fork":false,"pushed_at":"2023-11-11T11:44:19.000Z","size":327,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-23T23:29:24.789Z","etag":null,"topics":["graphql","graphql-php","php"],"latest_commit_sha":null,"homepage":"https://github.com/graphpql","language":"PHP","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/graphpql.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-07T11:30:47.000Z","updated_at":"2024-07-23T23:29:43.209Z","dependencies_parsed_at":"2024-07-23T23:29:38.965Z","dependency_job_id":"c3762fd3-94ca-4f53-a132-5d792a22bcc4","html_url":"https://github.com/graphpql/graphpinator-where-directives","commit_stats":null,"previous_names":["graphpql/graphpinator-where-directives","infinityloop-dev/graphpinator-where-directives"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-where-directives","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-where-directives/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-where-directives/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Fgraphpinator-where-directives/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphpql","download_url":"https://codeload.github.com/graphpql/graphpinator-where-directives/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224500006,"owners_count":17321619,"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","graphql-php","php"],"created_at":"2024-11-13T18:18:13.090Z","updated_at":"2024-11-13T18:18:13.652Z","avatar_url":"https://github.com/graphpql.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraPHPinator Where directives [![PHP](https://github.com/infinityloop-dev/graphpinator-where-directives/workflows/PHP/badge.svg?branch=master)](https://github.com/infinityloop-dev/graphpinator-where-directives/actions?query=workflow%3APHP) [![codecov](https://codecov.io/gh/infinityloop-dev/graphpinator-where-directives/branch/master/graph/badge.svg)](https://codecov.io/gh/infinityloop-dev/graphpinator-where-directives)\n\n:zap::globe_with_meridians::zap: Executable directives to filter values in lists.\n\n## Introduction\n\nThis package allows client to filter list values using directives. Filtration happens on server, the most common use case is to save bandwidth when client knows exactly which data it needs.\n\n## Installation\n\nInstall package using composer\n\n```composer require infinityloop-dev/graphpinator-where-directives```\n\n## How to use\n\n\u003e :warning: **These directives do NOT replace standard and optimal filtering provided by arguments and underlying technologies.** These directives serve only as an addition to these.\n\n\u003e :warning: **These directives are executable directives. Their usage is requested by client.** Think twice before including this functionality on your server.\n\nIn order to enable where directives on your server, the only thing you need to do is to put selected directives to your `Container`. You may use all or only some.\n\n\u003e `ListWhereDirective` has a special requirement on `infinityloop-dev/graphpinator-constraint-directives`, which needs to be enabled first if you wish to use `@listWhere`.\n\nThis package contains following directives:\n\n- `\\Graphpinator\\WhereDirectives\\StringWhereDirective`\n- `\\Graphpinator\\WhereDirectives\\IntWhereDirective`\n- `\\Graphpinator\\WhereDirectives\\FloatWhereDirective`\n- `\\Graphpinator\\WhereDirectives\\BooleanWhereDirective`\n- `\\Graphpinator\\WhereDirectives\\ListWhereDirective`\n\n### Directive options\n\n#### Common options\n\nAll directives have three common arguments\n\n- `field` (String) - This optional argument allows filtering of nested structures. Represents path to navigate into filtered value.\n    - For more information visit following [section](#Field-argument).\n- `orNull` (Boolean) - Whether to accept null as a value which satisfies condition (default false).\n- `not` (Boolean) - Negate the result of value conditions (default false).\n\n#### Specific options\n\n- `@stringWhere`\n    - equals\n    - contains\n    - startsWith\n    - endsWith\n- `@intWhere` \u0026 `@floatWhere`\n    - equals\n    - greaterThan\n    - lessThan\n- `@booleanWhere`\n    - equals\n- `@listWhere`\n    - minItems\n    - maxItems\n\n#### Priority of operations\n\nPriority can be described using following code snippet:\n\n```php\n$conditionIsMet = $value === null\n    ? $orNull\n    : satisfiesSpecificConditions($value);\n$valueIsFilteredOut = $conditionIsMet === $not;\n```\nThis effectively means that `not` argument has lowest priority and negates even the `orNull` argument.\n\n### Field argument\n\nLet's say we have a list of `BlogPost` objects with some fields in it. \nThen, to receive all blogposts, we could have a query like this.\n\n```graphql\n{ blogposts { title content likeCount author { name } } }\n```\n\nWhat if client needs only popular blogpost, with more than 100 likes, and server provides no relevant filtering options?\n\n```graphql\n{ blogposts @intWhere(field: \"likeCount\", greaterThan: 100) { title content likeCount author { name } } }\n```\n\nWhat if client needs only post from author named \"Foo Bar\" ?\n\n```graphql\n{ blogposts @stringWhere(field: \"author.name\", equals: \"Foo Bar\") { title content likeCount author { name } } }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphpql%2Fgraphpinator-where-directives","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphpql%2Fgraphpinator-where-directives","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphpql%2Fgraphpinator-where-directives/lists"}