gramps-graphql/gramps

View on GitHub
docs/src/pages/data-sources/overview.mdx

Summary

Maintainability
Test Coverage
---
title: What Is a Data Source?
---

<PageDescription>

At its core, a GrAMPS data source is simply an organizational structure to make GraphQL servers easier to build out of modular components.

By following the GrAMPS structure, data sources become more manageable, testable, and shareable. Different teams can own and maintain data sources that are all composed together and exposed through a single GraphQL gateway.

Developers can even get full GraphQL schemas for third-party services simply by installing that service’s data source.

</PageDescription>

## The Anatomy of a Data Source

Every GraphQL data source exports a **GrAMPS object** which defines the following properties:

-   `namespace` — a unique name for the data source

-   `context` — an object to be used as the context for the resolvers

-   `typeDefs` — type definitions for a GraphQL schema
    (see [the GraphQL docs on schemas for more info](http://graphql.org/learn/schema/))

-   `resolvers` — an object containing resolver functions
    (see [the GraphQL docs on execution for more info](http://graphql.org/learn/execution/))

-   `mocks` — mock resolver functions
    (see [the Apollo docs on mocking for more info](https://www.apollographql.com/docs/graphql-tools/mocking.html))

## Why Follow the GrAMPS Standard?

-   Consistency, maintainability, and simplicity: data sources follow a
    predictable, well-documented format.
-   Centralized data, distributed maintenance (one endpoint, many repos)
-   Reusability: plug together community GrAMPS data sources with your own to
    build complex applications faster