GraphQL

since iSHOP 40

"GraphQL is an open spec for a flexible API layer. Put GraphQL over your existing backends to build products faster than ever before." (graphql.com)

Our GraphQL implementation offers:

  • methods to extend an existing iSHOP with new functionality.
  • a way for external clients to access an existing iSHOP.

The GraphQLAPIs for iSHOP are work-in-progress and incomplete in specification and implementation.

The project "ishop-graphql"

Frameworks used in this project:

The main concern of this project is to

  • provide the base integration of GraphQL into the iSHOP
  • provide a simple usage and exstensibility
  • provide the core schema definition, classes and POJOs
  • provide a grafical tool GraphiQL, runs in browser for introspection and tests

Note: The following might only be of interest for you if you are working in the backend part of a shop project. More information can be found in the iSHOP Developer Documentation. Please contact novomind if you need access.

The base schema and classes

This project only, and shall only, contains the schema definition and classes needed by every extension. The base schema can be found in /src/main/resources/graphql/core/schema.graphqls and contains the base GraphQL types

  • Query
  • Mutation
  • Subscription

The core schema can be found in /src/main/resources/graphql/core/core_schema.graphqls and contains the base iSHOP core types, interfaces and scalars like

  • IShopObject
  • Image
  • Category
  • Product
  • Item
  • MultiChannelSelector

Every globally needed type or interface should be added to these schema definitions. This can simply be done by adding a .graphqls file to your projects resource folder. Don't forget to add subfolders resources/graphql/core!

This project also implements the main GraphQL resolver classes

  • QueryResolver
  • MutationResolver
  • SubscriptionResolver

Every project can define own base type resolvers by implementing graphql.kickstart.tools.GraphQLQueryResolver, graphql.kickstart.tools.GraphQLMutationResolver or graphql.kickstart.tools.GraphQLSubscriptionResolver. Note that methods can only exists once for a resolver!

There are also base implementation of core type resolvers like

  • IShopObjectResolver
    • An interface which provides base data fetchers for id, fullyQualifiedId and valid
  • ItemResolver
    • An IShopObjectResolver of type com.novomind.ishop.core.Item
  • ProductResolver
    • An IShopObjectResolver of type com.novomind.ishop.core.Product
  • CategoryResolver
    • An IShopObjectResolver of type com.novomind.ishop.core.Category

Every project can define own IShopObject type resolvers by implementing com.novomind.ishop.graphql.resolvers.IShopObjectResolver. Note that methods can only exists once for a resolver!