{"id":20815359,"url":"https://github.com/teamdeeson/simple_graphql","last_synced_at":"2025-09-12T21:36:45.123Z","repository":{"id":147156359,"uuid":"436065406","full_name":"teamdeeson/simple_graphql","owner":"teamdeeson","description":"A wrapper around the webonyx graphql library for creating Drupal based schemas","archived":false,"fork":false,"pushed_at":"2024-04-03T16:51:05.000Z","size":15,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T15:44:01.145Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teamdeeson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-08T00:21:40.000Z","updated_at":"2021-12-08T00:50:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"4345173c-5008-4738-b371-4b75d3a070cc","html_url":"https://github.com/teamdeeson/simple_graphql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teamdeeson%2Fsimple_graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teamdeeson%2Fsimple_graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teamdeeson%2Fsimple_graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teamdeeson%2Fsimple_graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teamdeeson","download_url":"https://codeload.github.com/teamdeeson/simple_graphql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243161322,"owners_count":20246041,"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":[],"created_at":"2024-11-17T21:21:53.253Z","updated_at":"2025-03-12T05:24:41.357Z","avatar_url":"https://github.com/teamdeeson.png","language":"PHP","readme":"This Drpual module is an alternative to https://www.drupal.org/project/graphql.\n\nIt's designed for use by developers to create a custom Graphql schema. At it's most simple, this module is just a wrapper around https://webonyx.github.io/graphql-php/ but it also\nallows you to compose the schema with a bunch of Drupal-specific functionality for handling entities, bundles, fields, entity referneces and more.\n\n## Getting started\n\n1. Download, install the module. There are no administration screens so nothing's going to look different at this point.\n2. Set yourself up with a custom module.\n3. Create a file in my_module/src/Pluing/SimpleGraphql. e.g. Schema.php.\n\n```php\n\u003c?php\nnamespace Drupal\\sn_graphql\\Plugin\\SimpleGraphql;\n\nuse Drupal\\Core\\Plugin\\ContainerFactoryPluginInterface;\nuse Drupal\\node\\Entity\\Node;\nuse Drupal\\simple_graphql\\Plugin\\DrupalSchemaDecorator;\nuse Drupal\\simple_graphql\\Plugin\\SchemaInterface as PluginSchemaInterface;\nuse GraphQL\\Language\\AST\\TypeDefinitionNode;\nuse GraphQL\\Server\\ServerConfig;\nuse Symfony\\Component\\DependencyInjection\\ContainerInterface;\n\n/**\n * @Schema(\n *  id = \"my_module_graphql_schema\",\n *  path = \"/graphql\",\n *  schemaFile = \"src/schema.graphql\",\n * )\n */\nclass Schema implements PluginSchemaInterface, ContainerFactoryPluginInterface {\n  protected DrupalSchemaDecorator $drupalSchemaDecorator;\n\n  protected $typeConfigDecorator;\n\n  public function __construct(DrupalSchemaDecorator $drupalSchemaDecorator, array $fieldResolvers) {\n    $this-\u003edrupalSchemaDecorator = $drupalSchemaDecorator;\n    $this-\u003etypeConfigDecorator = $this-\u003edrupalSchemaDecorator-\u003egetTypeConfigDecorator($fieldResolvers);\n  }\n\n  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {\n    $fieldResolvers = [\n      $container-\u003eget(\"simple_graphql.graphql.fieldResolver.entityReferenceFieldResolver\"),\n      $container-\u003eget(\"simple_graphql.graphql.fieldResolver.nodeFieldResolver\"),\n      $container-\u003eget(\"simple_graphql.graphql.fieldResolver.textFieldResolver\"),\n      $container-\u003eget(\"simple_graphql.graphql.fieldResolver.drupalEntityFieldResolver\"),\n    ];\n    return new self($container-\u003eget(\"simple_graphql.plugin.drupalSchemaDecorator\"), $fieldResolvers);\n  }\n\n  public function schemaTypeConfigDecorator($typeConfig, TypeDefinitionNode $typeDefinitionNode) {\n    return ($this-\u003etypeConfigDecorator)($typeConfig, $typeDefinitionNode);\n  }\n\n  public function configureServer(ServerConfig $serverConfig): ServerConfig {\n    $serverConfig-\u003esetRootValue([\"node\" =\u003e Node::load(1)]);\n\n    return $this-\u003edrupalSchemaDecorator-\u003ewithDrupal($serverConfig);\n  }\n}\n```\n\n4. Create a schema file, e.g schema.graphql\n\n```graphql\ntype Query {\n  node: Node\n}\n\ninterface FormattedFieldBase {\n  value: String!\n  format: String!\n  processed: String!\n}\n\ntype FormattedField implements FormattedFieldBase {\n  value: String!\n  format: String!\n  processed: String!\n}\n\ntype FormattedFieldWithSummary implements FormattedFieldBase {\n  value: String!\n  format: String!\n  processed: String!\n  summary_computed: String!\n}\n\ntype LinkField {\n  url: String!\n}\n\ntype LinkFieldWithTitle {\n  url: String!\n  title: String!\n}\n\ntype LinkFieldWithTitleAndChildren {\n  url: String!\n  title: String!\n  children: [LinkFieldWithTitle!]\n}\n\n#\n# Content types\n#\n\nenum VersionStatus {\n  PUBLISHED\n  DRAFT\n  PREVIOUS_REVISION\n  PREVIEW\n}\n\ninterface Node @entityType {\n  id: String!\n  title: String!\n  status: Boolean!\n  path: String!\n  editUrl: String\n  defaultVersionUrl: String\n  latestVersionUrl: String\n  versionStatus: VersionStatus\n}\n\ndirective @entityType on INTERFACE | UNION\ndirective @entity(type: String!, bundle: String!) on OBJECT\n\ntype BasicPageNode implements Node @entity(type: \"node\", bundle: \"page\") {\n  id: String!\n  title: String!\n  status: Boolean!\n  path: String!\n  editUrl: String\n  defaultVersionUrl: String\n  latestVersionUrl: String\n  versionStatus: VersionStatus\n  body(trimLength: Int = 120): FormattedFieldWithSummary\n}\n```\n\n5. Clear cache. You'll also need to do this any time you make a change to the schema file. You should now have an API up and running at /graphql.\n\n### Notes\n\nThere's no routing at the moment. The example above just loads and returns the node with id 1. I've got some code ready for routing, just haven't had time to put it in yet.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteamdeeson%2Fsimple_graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteamdeeson%2Fsimple_graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteamdeeson%2Fsimple_graphql/lists"}