Skip to content

Commit

Permalink
Add integration tests for nested files (#4754)
Browse files Browse the repository at this point in the history
Some tests were missing to ensure that files nested within other GraphQL
types still resolved correctly, so this commit addresses that.

Fixes #4709 

<!-- start metadata -->
---

**Checklist**

Complete the checklist (and note appropriate exceptions) before the PR
is marked ready-for-review.

- [ ] Changes are compatible[^1]
- [ ] Documentation[^2] completed
- [ ] Performance impact assessed and acceptable
- Tests added and passing[^3]
    - [ ] Unit Tests
    - [x] Integration Tests
    - [ ] Manual Tests

**Exceptions**

*Note any exceptions here*

**Notes**

[^1]: It may be appropriate to bring upcoming changes to the attention
of other (impacted) groups. Please endeavour to do this before seeking
PR approval. The mechanism for doing this will vary considerably, so use
your judgement as to how and when to do this.
[^2]: Configuration is an important part of many changes. Where
applicable please try to document configuration examples.
[^3]: Tick whichever testing boxes are applicable. If you are adding
Manual Tests, please document the manual testing (extensively) in the
Exceptions.
  • Loading branch information
nicholascioli committed Mar 7, 2024
1 parent 986d664 commit d5db9f8
Show file tree
Hide file tree
Showing 3 changed files with 244 additions and 265 deletions.
122 changes: 0 additions & 122 deletions apollo-router/tests/fixtures/file_upload/multiple_subgraph.graphql

This file was deleted.

Expand Up @@ -23,11 +23,8 @@ directive @link(url: String, as: String, for: link__Purpose, import: [link__Impo
scalar join__FieldSet

enum join__Graph {
ACCOUNTS @join__graph(name: "accounts", url: "https://accounts.demo.starstuff.dev/")
INVENTORY @join__graph(name: "inventory", url: "https://inventory.demo.starstuff.dev/")
PRODUCTS @join__graph(name: "products", url: "https://products.demo.starstuff.dev/")
REVIEWS @join__graph(name: "reviews", url: "https://reviews.demo.starstuff.dev/")
UPLOADS @join__graph(name: "uploads", url: "http://127.0.0.1:4005/")
UPLOADS_CLONE @join__graph(name: "uploads_clone", url: "http://127.0.0.1:4006/")
}

scalar link__Import
Expand All @@ -44,53 +41,11 @@ enum link__Purpose {
EXECUTION
}

type Product
@join__type(graph: INVENTORY, key: "upc")
@join__type(graph: PRODUCTS, key: "upc")
@join__type(graph: REVIEWS, key: "upc")
{
upc: String!
weight: Int @join__field(graph: INVENTORY, external: true) @join__field(graph: PRODUCTS)
price: Int @join__field(graph: INVENTORY, external: true) @join__field(graph: PRODUCTS)
inStock: Boolean @join__field(graph: INVENTORY)
shippingEstimate: Int @join__field(graph: INVENTORY, requires: "price weight")
name: String @join__field(graph: PRODUCTS)
reviews: [Review] @join__field(graph: REVIEWS)
reviewsForAuthor(authorID: ID!): [Review] @join__field(graph: REVIEWS)
}

type Query
@join__type(graph: ACCOUNTS)
@join__type(graph: INVENTORY)
@join__type(graph: PRODUCTS)
@join__type(graph: REVIEWS)
{
me: User @join__field(graph: ACCOUNTS)
topProducts(first: Int = 5): [Product] @join__field(graph: PRODUCTS)
}

type Review
@join__type(graph: REVIEWS, key: "id")
{
id: ID!
body: String
author: User @join__field(graph: REVIEWS, provides: "username")
product: Product
}

type User
@join__type(graph: ACCOUNTS, key: "id")
@join__type(graph: REVIEWS, key: "id")
{
id: ID!
name: String @join__field(graph: ACCOUNTS)
username: String @join__field(graph: ACCOUNTS) @join__field(graph: REVIEWS, external: true)
reviews: [Review] @join__field(graph: REVIEWS)
}


scalar Upload
@join__type(graph: UPLOADS)
scalar UploadClone
@join__type(graph: UPLOADS_CLONE)

type File
@join__type(graph: UPLOADS)
Expand All @@ -100,9 +55,34 @@ type File
encoding: String!
body: String!
}
type FileClone
@join__type(graph: UPLOADS_CLONE)
{
filename: String!
mimetype: String!
encoding: String!
body: String!
}

input NestedUpload
@join__type(graph: UPLOADS)
{
file: Upload!
}

type Query
@join__type(graph: UPLOADS)
@join__type(graph: UPLOADS_CLONE)
{
empty: String
}

type Mutation
@join__type(graph: UPLOADS)
@join__type(graph: UPLOADS_CLONE)
{
singleUpload(file: Upload): File @join__field(graph: UPLOADS)
singleUploadClone(file: UploadClone): FileClone @join__field(graph: UPLOADS_CLONE)
multiUpload(files: [Upload!]!): [File!]! @join__field(graph: UPLOADS)
nestedUpload(nested: NestedUpload): File @join__field(graph: UPLOADS)
}

0 comments on commit d5db9f8

Please sign in to comment.