-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
- @key
- ref should not be mapper. PR
- Interface with
@keymust generate__resolveReference. PR - Ref types are scalar output type (?)
-
__resolveReferenceshould return mapper if available - Defining advanced @keys
- composite
@keywork e.g.@key(fields: "id anotherId") - nested
@keywork e.g.@key(fields: "id organization { id }") - multiple
@keywork e.g.@key(fields: "id") @key(fields: "id2")
- composite
- @interfaceObject
- No types required
- @extends
- No types required
- @shareable
- No types required: this is used during composition check to say whether a field can be resolved by multiple subgraphs or used as another Graph's
@key(which is implicitly shareable)
- No types required: this is used during composition check to say whether a field can be resolved by multiple subgraphs or used as another Graph's
- @inaccessible
- If an enum member is marked with inaccessible, omit it from types, otherwise there could be runtime errors
- @override
- No types required: this is used to migrate field resolving from one subgraph to another
- @external
- If a field is marked with
@external, do not generate resolver types. - If a field is marked with
@external, do not change other fields' signature fromParentType(using mappers) toGraphQLRecursivePickPR - If a type is marked with
@external, generate the base type but not resolver types - Server Preset must not generate resolvers i.e. use resolver types instead of type interface to compare fields against mappers
- If a field is marked with
- @provides
- When
@providesis used on an@externalfield, the field resolver type is generated -
@providesworks with nested path (Note: currently it is not generating the field resolver)
- When
- @requires
- Fields marked with
@requiresmust use the normal mappers, instead of theGraphQLRecursivePickwith the@keyand@requiresfields. - When there's a field marked with
@requires, the__resolveReference's ref must have a union of possible combination e.g.
- Fields marked with
type User @key(fields: "id") {
id: ID!
title: PersonTitle! @external
firstName: String! @external
lastName: String! @external
birthYear: Int! @external
fullName: String! @requires(fields: "firstName lastName")
fullNameWithTitle: String! @requires(fields: "firstName lastName title")
age: Int! @requires(fields: "birthyear")
}Then, the type of reference is something like:
ReferenceResolver<
Maybe<ResolversTypes["User"]>,
{ __typename: "User" }
& GraphQLRecursivePick<ParentType, { id: true }> // <-- from @key, must always be here
& GraphQLRecursivePick<ParentType, { firstName?: true; lastName?: true }> <-- from @requires
& GraphQLRecursivePick<ParentType, { firstName?: true; lastName?: true, title?: true }> <-- from @requires
& GraphQLRecursivePick<ParentType, { birthyear?: true }> <-- from @requires
, ContextType
>
Note: the type for @requires needs a re-think because if fullName is in the selection set, firstName and lastName must exist in the ref together. The example above is saying there could be a scenario where firstName is there but lastName is not. We need something like AnyCombinationOf<ArrayOfRequiresOptions>
- @tag
- No types needed
- @composeDirective
- No types needed
Enterprise directives
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels