apollo-server icon indicating copy to clipboard operation
apollo-server copied to clipboard

@Provides Directive Unexpected Error

Open ksaldana1 opened this issue 7 years ago • 6 comments

Reproduction Repo: https://github.com/ksaldana1/provides-fed-repro

I am pretty confused by what I am seeing here. I followed the example from the docs, and from what I can tell the structure I have isn't any different from the example provided in the federation-demo, but maybe I'm missing something really obvious.

Despite me labeling my fields, I'm still getting error messages such as : UnhandledPromiseRejectionWarning: GraphQLSchemaValidationError: [users] Kitchen.name -> is marked as @external but is not used by a @requires, @key, or @provides directive.

This was happening on a larger project and seemed to continue when I scaled it down.

Thanks for all your hard work! Federation is really awesome!

ksaldana1 avatar Jun 04 '19 05:06 ksaldana1

@ksaldana1 this does indeed seem like a bug! @JakeDawkins can you take a look?

jbaxleyiii avatar Jun 04 '19 17:06 jbaxleyiii

I'm on it!

JakeDawkins avatar Jun 04 '19 21:06 JakeDawkins

@JakeDawkins, any update on this? I seem to be having a similar issue:

extend type TruckType @key(fields: "id"){
    id: ID! @external
}

throws the following error:

Exception: GraphQLSchemaValidationError: [inquiries] TruckType.id -> is marked as @external but is not used by a @requires, @key, or @provides directive

Thanks for the hard work!

JannesV avatar Jun 13 '19 13:06 JannesV

Hey @JannesV! Sorry for the slow response. I have a WIP PR open for the issue now. I have a couple more cases to fix, especially around @requires, but I'm trying to wrap it up quickly!

JakeDawkins avatar Jun 18 '19 13:06 JakeDawkins

Thanks! I've just found out my error was due to my own ignorance. I forgot to specify the @key directive on the type I'm extending. When including that it resolved my issue.

JannesV avatar Jun 18 '19 13:06 JannesV

Thanks for getting this fixed @JakeDawkins ! The first time I read through the federation docs I thought "I don't think I'll need these advanced features...", but then after I grokked them it felt hard to live without. So thanks for being one step ahead on the features!

ksaldana1 avatar Jun 21 '19 19:06 ksaldana1