menu

Apollo

A community of developers, designers and others who love Apollo and GraphQL. 🚀

Channels
# All channels
view-forward
# General
view-forward
# Apollo Angular
view-forward
# Announcements
view-forward
# Apollo Android
view-forward
# Apollo Client
view-forward
# Apollo iOS
view-forward
# Apollo Link
view-forward
# Apollo Link Rest
view-forward
# Local State
view-forward
# Apollo Platform
view-forward
# Apollo Server
view-forward
# Apollo Tooling
view-forward
# Contributing
view-forward
# Docs
view-forward
# Events
view-forward
# GraphQL Tools
view-forward
# Jobs
view-forward
# Random
view-forward
# React Apollo
view-forward
# Showcase
view-forward
# Subscriptions
view-forward
# Testing
view-forward
# Vue Apollo
view-forward
Team

Testing subgraph with Query stub in federated schema

November 20, 2019 at 3:19pm

Testing subgraph with Query stub in federated schema

November 20, 2019 at 3:19pm
Hi,
We are building a federated graph and have a problem regarding testing the independent subgraphs.
We have a subgraph that defines a field on a type with a parent provided by another service at the Query level. The problem is that the organization and organizations fields on the Query type are required in order to access/test the keyMetrics field on the extended Organization type. However, these fields cannot be defined in both schemas at the same time, since the Query type does not have a (error: "Query.organizations -> is marked as but is not used by a , , or directive.). We would like to test the two graphs independently, but have not found a way to exclude the organization and organizations fields on the gateway level while maintaining them at the "subgraph"/service level for testing.
These are our two schemas:
const typeDefs = gql`
scalar DateTime
type Organization @key(fields: "id") {
id: ID
name: String
subdomain: String
createdAt: DateTime
updatedAt: DateTime
}
extend type Query {
organization(id: ID): Organization
organizations: [Organization]
}
`;
Second schema:
const typeDefs = gql`
type KeyMetrics {
date: DateTime
invoiceCount: Int
accountingCount: Int
potentialCount: Int
}
extend type Organization @key(fields: "id") {
id: ID @external
keyMetrics(
fromDate: DateTime
toDate: DateTime
): [KeyMetrics]
}
extend type Query {
# organization(id: ID): Organization @external
# organizations: [Organization] @external
}
`;
Is there any way we can test the subgraphs using the same schemas as we use for the federated service?
Thanks

March 25, 2020 at 7:26pm
Any response about it ?
  • reply
  • like