Files
genqlient/generate/testdata/queries/ComplexInlineFragments.graphql
T
Ben Kraft 2eba9a2c30 Reorganize documentation to make room to grow (#84)
## Summary:
In this commit I reorganize much of our documentation into a new `docs`
directory, where there will hopefully be more room to grow and to
organize things in a user-friendly way.  There's almost no net-new
documentation, although of course it's a great time to review it anyway.

In particular:
- I moved the documentation for the `genqlient.yaml` config file into an
  example file instead of GoDoc (which now just points to the example
  file); I think this will be a lot clearer for casual users.
- I moved the documentation for the `@genqlient` directive out of GoDoc
  and into a GraphQL schema file (since while it's a comment it's all
  real syntax), likewise, and made the `GenqlientDirective` type private
  (since there's now nothing useful to do with it).
- I moved `DESIGN.md` and the logo into `docs/` (just to keep the
  toplevel a bit cleaner), and separated the Contributing section of the
  README into `docs/CONTRIBUTING.md` (which github will automatically
  link on various issue and PR pages).

This leaves it so that:
- README.md is the only documentation at the toplevel (and will become
  just the high-level introduction as I add more user docs to `docs/`)
- GoDoc is only documentation for if you want to call genqlient
  programmatically (which is fairly limited as the API surface is quite
  small: it's now just Main, Generate, and Config, plus a constructor, a
  single method, and a bunch of fields on the latter)

In future commits, I'll add some more new documentation to the `docs`
directory.

Issue: https://github.com/Khan/genqlient/issues/26

## Test plan:
make check (and read the docs)


Author: benjaminjkraft

Reviewers: jvoll, benjaminjkraft, aberkan, dnerdy, MiguelCastillo, mahtabsabet

Required Reviewers: 

Approved By: jvoll

Checks:  Lint,  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Test (1.17),  Test (1.16),  Test (1.15),  Test (1.14),  Lint

Pull Request URL: https://github.com/Khan/genqlient/pull/84
2021-09-10 16:03:30 -07:00

70 lines
2.2 KiB
GraphQL

# We test all the spread cases from docs/DESIGN.md, see there for more context
# on each, as well as various other nonsense. But for abstract-in-abstract
# spreads, we can't test cases (4b) and (4c), where I implements J or vice
# versa, because gqlparser doesn't support interfaces that implement other
# interfaces yet.
query ComplexInlineFragments {
root {
id
... on Topic { schoolGrade } # (1) object spread in object scope
... on Content { name } # (3) abstract spread in object scope
}
randomItem {
id
... on Article { text } # (2) object spread in abstract scope
... on Content { name } # (4a) abstract spread in abstract scope, I == J
... on HasDuration { duration } # (4d) abstract spread in abstract scope, neither implements the other
}
repeatedStuff: randomItem {
id
id
url
otherId: id
... on Article {
name
text
otherName: name
}
... on Content {
id
name
otherName: name
}
... on HasDuration { duration }
}
conflictingStuff: randomItem {
# These two have different types! Naming gets complicated. Note GraphQL
# says [1] that you can only have such naming conflicts when the fields are
# both on object-typed spreads (reasonable, so they can never collide) and
# they are of "shapes that can be merged", e.g. both nullable objects,
# which seems very strange to me but is the most interesting case for us
# anyway (since where we could have trouble is naming the result types).
# [1] https://spec.graphql.org/draft/#SameResponseShape()
# TODO(benkraft): This actually generates the wrong thing right now (the
# two thumbnail types get the same name, and one clobbers the other). Fix
# in a follow-up commit.
... on Article { thumbnail { id thumbnailUrl } }
... on Video { thumbnail { id timestampSec } }
}
nestedStuff: randomItem {
... on Topic {
children {
id
... on Article {
text
parent {
... on Content {
name
parent {
... on Topic {
children { id name }
}
}
}
}
}
}
}
}
}