# Making Use of Inheritance when generating GraphQL Schemas

**URL:** <https://community.stardog.com/t/making-use-of-inheritance-when-generating-graphql-schemas/3474>\
**Category:** Support\
**Created:** [January 24, 2022, 6:13pm UTC](https://community.stardog.com/t/making-use-of-inheritance-when-generating-graphql-schemas/3474 "2022-01-24T18:13:43Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Tobias\_Schweizer](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/tobias_schweizer/32/1240_2.png) [@Tobias\_Schweizer](https://community.stardog.com/u/Tobias_Schweizer)\
**Post date:** [January 27, 2022, 9:42am UTC](https://community.stardog.com/t/making-use-of-inheritance-when-generating-graphql-schemas/3474/3 "2022-01-27T09:42:55Z")

</div>

Hi Evren,

Thanks a lot for your reply. I'll try to provide a minimal example.

`shapes.json` contains SHACL shapes for `schema:Thing` and `schema:Person` (we are using `sh:targetClass`). `ontology.json` expresses the subclass relation between person and thing.  
Now when this data is loaded using `load_shapes.sh`, I get the following result:

```graphql
schema {
  query: QueryType
}

type Organization @iri(value : "http://schema.org/Organization") {
  iri: ID!
}

type Person @iri(value : "http://schema.org/Person") {
  additionalName: [String] @iri(value : "http://schema.org/additionalName")
  address: String @iri(value : "http://schema.org/address")
  affiliation: [Organization]! @iri(value : "http://schema.org/affiliation")
  birthDate: String @iri(value : "http://schema.org/birthDate")
  deathDate: String @iri(value : "http://schema.org/deathDate")
  email: String @iri(value : "http://schema.org/email")
  familyName: String! @iri(value : "http://schema.org/familyName")
  givenName: String! @iri(value : "http://schema.org/givenName")
  honorificPrefix: String @iri(value : "http://schema.org/honorificPrefix")
  honorificSuffix: String @iri(value : "http://schema.org/honorificSuffix")
  iri: ID!
  jobTitle: [String]! @iri(value : "http://schema.org/jobTitle")
}

type QueryType {
  Organization: Organization
  Person: Person
  Thing: Thing
}

type Thing @iri(value : "http://schema.org/Thing") {
  alternateName: [String] @iri(value : "http://schema.org/alternateName")
  description: ID @iri(value : "http://schema.org/description")
  identifier: ID @iri(value : "http://schema.org/identifier")
  image: ID @iri(value : "http://schema.org/image")
  iri: ID!
  name: String! @iri(value : "http://schema.org/name")
  sameAs: [ID] @iri(value : "http://schema.org/sameAs")
  url: [ID] @iri(value : "http://schema.org/url")
}

```

Regarding the generated schema, I have the following comments:

1. I'd expect person to have also the properties / fields defined for thing.

2. I also noticed that `QueryType` lacks the @iri decorators resulting in SPARQL queries that return no result, same as described [here](https://community.stardog.com/t/manually-registered-graphql-schemas/3300/5).

3. How is `sh:or` handled? If two datatypes are allowed on a property's range, will there be a union in the schema?

I've gained some experience in transforming the shapes graph for different purposes. Maybe the shapes need some more info (they do not contain inheritance info directly, only indirectly via their target classes)?

Thanks a lot for your feedback.

Kind regards,

Tobias

[shapes.json](https://community.stardog.com/uploads/short-url/cx6eYXWGpz1NI67bOi9eLhIhQ0G.json) (8.8 KB)  
[ontology.json](https://community.stardog.com/uploads/short-url/cfFZxMovHlny9ogh0rcWDD3oolA.json) (1.3 KB)  
[load\_shapes.sh](https://community.stardog.com/uploads/short-url/oLCpD3vdvVQElEL7LOWkhPXqFFR.sh) (352 Bytes)

---

_[View the full topic](https://community.stardog.com/t/making-use-of-inheritance-when-generating-graphql-schemas/3474)._
