|
| 1 | +# Reuse Domain |
| 2 | + |
| 3 | +Making Wikimedia's linked open data accessible to the world, enabling the knowledge to be used to build impactful products and projects ✨ |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +The functionality described here is provided by the Wikibase GraphQL API which is primarily intended for data reusers. The endpoint can be found on the wiki's `Special:WikibaseGraphQL` special page. |
| 8 | + |
| 9 | +### Labels of linked entities |
| 10 | + |
| 11 | +Queries of this type allow users to request labels of entities that are used in Statements, such as the Statement Property or Items in Statement values. |
| 12 | + |
| 13 | +Example request: |
| 14 | +The following query fetches the Item with the ID Q64, including its English label, all P31 statements, the English label of the Statement Property and the IDs and labels of items used as the Statement value. |
| 15 | +```graphql |
| 16 | +{ |
| 17 | + item(id: "Q64") { |
| 18 | + label(languageCode: "en") |
| 19 | + statements(propertyId: "P31") { |
| 20 | + property { |
| 21 | + label(languageCode: "en") |
| 22 | + } |
| 23 | + value { |
| 24 | + ... on ItemIdValue { |
| 25 | + content { |
| 26 | + id |
| 27 | + label(languageCode: "en") |
| 28 | + } |
| 29 | + } |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +## Development |
| 37 | + |
| 38 | +### Configuration |
| 39 | + |
| 40 | +During this initial development phase, the GraphQL API can be enabled with the `tmpEnableGraphQL` feature toggle setting. |
| 41 | + |
| 42 | +``` |
| 43 | +$wgWBRepoSettings['tmpEnableGraphQL'] = true; |
| 44 | +``` |
| 45 | + |
| 46 | +### Directory Structure |
| 47 | + |
| 48 | +- `src/` |
| 49 | + - `Application/` |
| 50 | + - `UseCases/`: Primary ports of the application core |
| 51 | + - `Domain/` |
| 52 | + - `Model/`: Entities and value objects |
| 53 | + - `Services/`: Secondary ports, i.e. persistence interfaces such as retrievers |
| 54 | + - `Infrastructure/`: Secondary adapters, i.e. implementations of interfaces defined in the application core |
| 55 | + - `DataAccess/`: Implementations of persistence services |
| 56 | + - `GraphQL/`: The GraphQL service implementation, resolvers, schema and types |
| 57 | +- `tests/` |
| 58 | + - `phpunit/`: integration and unit tests using the phpunit framework |
| 59 | + |
| 60 | +### Useful commands |
| 61 | + |
| 62 | +Please run the following commands from the Wikibase repository's root directory using [mwcli](https://www.mediawiki.org/wiki/Cli): |
| 63 | +* running all tests: `mw dev mw exec -- composer -d ../.. phpunit:entrypoint extensions/Wikibase/repo/domains/reuse/tests/phpunit/` |
| 64 | +* generating the GraphQL schema SDL: `mw dev mediawiki mwscript ./extensions/Wikibase/repo/domains/reuse/src/Infrastructure/GraphQL/GenerateSDL.php` |
| 65 | +* linting: |
| 66 | + * `mw dev mw composer phpcs:prpl` |
| 67 | + * `mw dev mw composer phpcs repo/domains/reuse/` |
0 commit comments