# Is @inaccessible a directive that is still available?

**URL:** <https://community.apollographql.com/t/is-inaccessible-a-directive-that-is-still-available/6155>\
**Category:** Schema Design\
**Tags:** federation\
**Created:** [April 17, 2023, 10:27pm UTC](https://community.apollographql.com/t/is-inaccessible-a-directive-that-is-still-available/6155 "2023-04-17T22:27:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasu](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/vasu/32/4184_2.png) [@vasu](https://community.apollographql.com/u/vasu)\
**Post date:** [April 17, 2023, 10:27pm UTC](https://community.apollographql.com/t/is-inaccessible-a-directive-that-is-still-available/6155/1 "2023-04-17T22:27:49Z")

</div>

Hi,

Am trying to use @inaccessible directive, but i get GraphQLError: Unknown directive “inaccessible”

Is this directive still valid?

thanks  
-Vasu

---

<div class="post-metadata">

**Author:** ![vasu](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/vasu/32/4184_2.png) [@vasu](https://community.apollographql.com/u/vasu)\
**Post date:** [April 20, 2023, 7:16pm UTC](https://community.apollographql.com/t/is-inaccessible-a-directive-that-is-still-available/6155/2 "2023-04-20T19:16:13Z")

</div>

Is there anyone who can help me with this question please?

---

<div class="post-metadata">

**Author:** ![dkuc](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/dkuc/32/2892_2.png) [@dkuc](https://community.apollographql.com/u/dkuc)\
**Post date:** [April 20, 2023, 7:50pm UTC](https://community.apollographql.com/t/is-inaccessible-a-directive-that-is-still-available/6155/3 "2023-04-20T19:50:33Z")

</div>

Hello 👋

`@inaccessible` is a valid federation v2 directive (docs → [Federation-specific GraphQL directives - Apollo GraphQL Docs](https://www.apollographql.com/docs/federation/federated-types/federated-directives#inaccessible)).

Make sure that library/framework you are using actually provides support for it though → [Federation-compatible subgraph implementations - Apollo GraphQL Docs](https://www.apollographql.com/docs/federation/building-supergraphs/supported-subgraphs)

Thanks,  
Derek

---

<div class="post-metadata">

**Author:** ![vasu](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/vasu/32/4184_2.png) [@vasu](https://community.apollographql.com/u/vasu)\
**Post date:** [April 24, 2023, 8:04pm UTC](https://community.apollographql.com/t/is-inaccessible-a-directive-that-is-still-available/6155/4 "2023-04-24T20:04:00Z")

</div>

thanks for the reply @dkuc , I tried this below subgraph. I think am unable to import the federation 2 schema . Can you please help

```auto
  extend schema @link(url: "https://specs.apollo.dev/federation/v2.3",as: "fed")

  type Post @key(fields: "id") {
    id: ID!
    title: String!
    author: User @provides(fields: "name")
    content: String! @inaccessible(reason:"Private var")
  }

  extend type User @key(fields: "id") {
    id: ID! @external
    posts: [Post]
    name : String! @external
  }

  extend type Query {
    post(id: ID!): Post
    posts: [Post]
  }

```

I get this error when i try to start

```auto
/Users/graphql_pox/posts/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:49
        throw new GraphQLSchemaValidationError_1.GraphQLSchemaValidationError(errors);
        ^

GraphQLSchemaValidationError: Unknown directive "@link".

```

---

<div class="post-metadata">

**Author:** ![dkuc](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/dkuc/32/2892_2.png) [@dkuc](https://community.apollographql.com/u/dkuc)\
**Post date:** [April 24, 2023, 8:55pm UTC](https://community.apollographql.com/t/is-inaccessible-a-directive-that-is-still-available/6155/5 "2023-04-24T20:55:48Z")

</div>

What versions of the libraries are you using? Make sure that you are using latest versions of the libs to ensure all federation features are supported.

Your `@link` directive should be importing federation directives, i.e.

```auto
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@external", "@inaccessible", "@key", "@provides"]

```

Few additional comments:

- Without explicit import (see above) you need to prefix federation directives with their namespace (default `federation __`, e.g. `@federation__ key`). Guessing you probably don’t need custom namespace (i.e. **as: “fed”** which would result in `@fed__key`) so I’d drop it.
- `extend type`/`@extends` were required in federation v1 and there is no need for it in federation v2 (you may want to keep the `extend schema` part so you don’t have to redefine default query/mutation fields).
- federation v2 does not require `@external` on `@key` fields (it was required in v1) - you can safely drop it from `User.id` field
- since `User.name` is only reachable through `@provides` path, this field will always be resolved locally so you don’t need `@external` there either (it was required in v1) - IF this field is reachable in this graph through some other path without `@provides` then keep the `@external`

---

<div class="post-metadata">

**Author:** ![vasu](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/vasu/32/4184_2.png) [@vasu](https://community.apollographql.com/u/vasu)\
**Post date:** [April 24, 2023, 9:15pm UTC](https://community.apollographql.com/t/is-inaccessible-a-directive-that-is-still-available/6155/6 "2023-04-24T21:15:51Z")

</div>

```auto
const { ApolloServer } = require('apollo-server');
const {gql} = require('graphql-tag');
const { buildFederatedSchema} = require('@apollo/federation');

const { PostsAPI,UsersAPI } = require('./postsapi.js');
const {LoggerPlugin} = require('./logger.js')
const typeDefs = gql`

  type Post @key(fields: "id") {
    id: ID!
    title: String!
    author: User @provides(fields: "name")
    content: String!
  }

extend type User @key(fields: "id") {
    id: ID! @external
    posts: [Post]
    name : String! @external
  }

extend type Query {
    post(id: ID!): Post
    posts: [Post]
  }
`;

const resolvers = {
  //<some code here>
};

const schema = buildFederatedSchema([{ typeDefs, resolvers }]);

const server = new ApolloServer({
    plugins : [LoggerPlugin],
    schema: buildFederatedSchema([{ typeDefs, resolvers }]),
    dataSources: () => ({
      postsAPI: new PostsAPI(),
      usersAPI: new UsersAPI()
    }),
  });
  
  server.listen({host:"0.0.0.0",port:6002}).then(({ url }) => {
    console.log(`🚀 Subgraph ready at ${url}`);
  });
  

```

Looks like @apollo/federation doesnt have these directives. @apollo/subgraph or @apollo/federation-internals has it. Should I use buildFederatedSchema or buildSubGraphSchema for a subgraph?

Any pointers to documentation will be helpful

---

<div class="post-metadata">

**Author:** ![vasu](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/vasu/32/4184_2.png) [@vasu](https://community.apollographql.com/u/vasu)\
**Post date:** [April 24, 2023, 11:39pm UTC](https://community.apollographql.com/t/is-inaccessible-a-directive-that-is-still-available/6155/7 "2023-04-24T23:39:29Z")

</div>

I was able to get it working. Thanks for the help.

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:49pm UTC](https://community.apollographql.com/t/is-inaccessible-a-directive-that-is-still-available/6155/8 "2025-02-06T20:49:03Z")

</div>

Archived on February 6, 2025, 8:49pm UTC


