graphdoc icon indicating copy to clipboard operation
graphdoc copied to clipboard

federation support: generation of documents extend types

Open ravisastryk opened this issue 5 years ago • 2 comments

It would be good to generate documentation with schemas that has federation support. Reference https://www.apollographql.com/docs/apollo-server/federation/introduction/

For example, the following federated query fails to generate document

extend type Query {
  me: User
}

type User @key(fields: "id") {
  id: ID!
  username: String!
}

error message:

Must provide schema definition with query type or a type named Query

ravisastryk avatar May 04 '20 23:05 ravisastryk

@ravisastryk Not sure if it helps, but in case of using federation, it would make sense to generate docs based on Gateway introspection (not downstream services) or on a JSON file produced by apollo client:download-schema command. I don't know your use case ofc, but worked for me.

treble-snake avatar Oct 12 '20 14:10 treble-snake

There are two cases here:

  1. I want to document the entire federated schema. I think this is possible today by taking your federated schemas, putting them together using the composeAndValidate function from @apollo/federation, and then running graphdoc on the resulting schema.... I'm having some trouble with composeAndValidate dropping docstrings, so the resulting documentation is less than helpful.

  2. I want to document each service that makes up a federated service separately. I'm still trying to figure out how to do this, and it may involve additional direct support from graphdoc, because in this case you're intentionally wanting to parse and document an "incomplete" schema with @extends directives for types that don't exist. It isn't just for Query and Mutation, but any other extended types.

bsmedberg-xometry avatar Dec 07 '20 19:12 bsmedberg-xometry