Skip to content

Commit

Permalink
Api / Graphql : Allow version as singleton argument on singleton (#…
Browse files Browse the repository at this point in the history
…22184)

Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
  • Loading branch information
joselcvarela and paescuj committed Apr 12, 2024
1 parent 39d2188 commit 75c03bd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-pillows-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@directus/api': patch
---

Added missing `version` argument to singleton GraphQL queries
4 changes: 4 additions & 0 deletions api/src/services/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,10 @@ export class GraphQLService {
type: GraphQLString,
},
};
} else {
resolver.args = {
version: GraphQLString,
};
}

ReadCollectionTypes[collection.collection]!.addResolver(resolver);
Expand Down
11 changes: 8 additions & 3 deletions docs/reference/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,11 @@ Get an item that exists in Directus.

```graphql
type Query {
<collection>_by_id(id: ID!): <collection>
<collection>_by_id(id: ID!, version: String): <collection>
}

type Query {
<collection>_by_version(id: ID!, version String!): <collection_version>
<collection>_by_version(id: ID!, version: String!): <collection_version_raw>
}
```

Expand Down Expand Up @@ -277,7 +278,11 @@ List a singleton item in Directus.

```graphql
type Query {
<collection>_by_version(version: String): <collection>
<collection>(version: String): <collection>
}

type Query {
<collection>_by_version(version: String!): <collection_version_raw>
}
```

Expand Down

0 comments on commit 75c03bd

Please sign in to comment.