# Querying/Mutating Linked Data with GraphQL

**URL:** https://forum.solidproject.org/t/querying-mutating-linked-data-with-graphql/3638
**Category:** Build a Solid App
**Created:** [December 2, 2020, 9:42am UTC](https://forum.solidproject.org/t/querying-mutating-linked-data-with-graphql/3638 "2020-12-02T09:42:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![anon85132706](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon85132706](https://forum.solidproject.org/u/anon85132706)
#### Post date: [December 2, 2020, 9:42am UTC](https://forum.solidproject.org/t/querying-mutating-linked-data-with-graphql/3638/1 "2020-12-02T09:42:38Z")

</div>

As previously mentioned I was interested in porting GraphQL to work with linked data. I forked the graphql javascript implementation and added rules to the parser to work with namespace prefixes. The working title is [webql](https://github.com/ludwigschubi/webql).

It completes namespace prefixes by using the namespaces in [solid-namespace](https://github.com/jeff-zucker/solid-namespace) + additional namespaces that can be declared in a json file similar to how they’re declared in solid-namespace; the path to this file needs to be set in CUSTOM\_NAMESPACES\_PATH

The client that helps to load and patch linked data resources and makes them consumable by GraphQL is at [webql-client](https://github.com/0wntech/webql-client)

Apart from the changes made to the graphql vanilla implementation, i also forked ([webql-nexus-schema](https://github.com/ludwigschubi/webql-nexus-schema/)) [graphql-nexus-schema](https://github.com/graphql-nexus/schema) for an easier way to declare graphql schemas; it now also account for the namespace prefixes in the schema.

And if you are now curious how this can be used i built a small profile editor that exemplifies the functionalities: [https://webql-demo.owntech.de](https://webql-demo.owntech.de) ([Source](https://github.com/ludwigschubi/webql-demo))

You can see in src/api/objects/person how a file structure can look like and how it can be used to declare types, mutations and queries. I also have some useful helpers in src/api/schema.ts that use [react-query](https://github.com/tannerlinsley/react-query) to transform operations into react hooks. In src/components/Profile.tsx you can see these operations in action.

As I am just finishing this in time for my uni exams I didn’t get to properly document it, but that will follow. So for now it is unfortunately all over the place 😕 However typescript should expose most of the api’s so if you are already somewhat familiar with graphql and you want to try it out, you already can. I also plan to implement [graphql-codegen](https://github.com/dotansimha/graphql-code-generator) to work with the webql types, queries & mutations, to make it an even better developer experience.

Any feedback, opinions or issues are as always highly appreciated 🎊🙂

---

<div class="post-metadata">

### Author: ![megoth](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/megoth/32/8_2.png) [@megoth](https://forum.solidproject.org/u/megoth)
#### Post date: [December 2, 2020, 2:53pm UTC](https://forum.solidproject.org/t/querying-mutating-linked-data-with-graphql/3638/2 "2020-12-02T14:53:01Z")

</div>

You might be interested in the work that’s being done on [GraphQL-LD](https://comunica.github.io/Article-ISWC2018-Demo-GraphQlLD/) by @rubensworks, @RubenVerborgh, and Miel Vander Sande.

---

<div class="post-metadata">

### Author: ![anon85132706](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon85132706](https://forum.solidproject.org/u/anon85132706)
#### Post date: [December 3, 2020, 2:22pm UTC](https://forum.solidproject.org/t/querying-mutating-linked-data-with-graphql/3638/3 "2020-12-03T14:22:55Z")

</div>

@megoth yeah i already checked it out and while I respect their approach I think we are not really working with the same goal in mind. Porting graphql to work with ld resources was mainly about making front-end devs have an easier time when it comes to structuring and maintaining a data schema, queries and mutations, like they have done for “regular” front-end apps where they might have used something like the apollo or the prisma client.  
It is not so much about enabling devs to do complex, rule-based sparql queries like it might be needed for a scientific endeavor, but more about building schemas that are reusable and doing simple queries that you expect to be typesafe for a production grade application.  
I’m not an expert in GraphQL, but to me it seems like a “backwards-compatible” (it isn’t 100%) is the best approach if you want some compatibility with existing tools.  
I can say from experience that a well maintained graphql schema is extremely helpful when adding features to an app and in the team that I am currently working in, it saves us a lot of nerves.

---

<div class="post-metadata">

### Author: ![anon85132706](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon85132706](https://forum.solidproject.org/u/anon85132706)
#### Post date: [December 3, 2020, 2:38pm UTC](https://forum.solidproject.org/t/querying-mutating-linked-data-with-graphql/3638/4 "2020-12-03T14:38:14Z")

</div>

Excuse me if i drifted away a bit there, that opinion wasn’t directed at you i just wanted to elaborate on why i am not using graphql-ld. And i think it’s a great effort just not exactly what i was looking for. Thank you for reaching out 🙂
