# TypeError: Cannot read properties of undefined (reading 'QUERY')\\n

**URL:** <https://community.apollographql.com/t/typeerror-cannot-read-properties-of-undefined-reading-query-n/7818>\
**Category:** Schema Design\
**Tags:** server, federation\
**Created:** [September 11, 2024, 1:56pm UTC](https://community.apollographql.com/t/typeerror-cannot-read-properties-of-undefined-reading-query-n/7818 "2024-09-11T13:56:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shail\_Patel](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/shail_patel/32/5293_2.png) [@Shail\_Patel](https://community.apollographql.com/u/Shail_Patel)\
**Post date:** [September 11, 2024, 1:56pm UTC](https://community.apollographql.com/t/typeerror-cannot-read-properties-of-undefined-reading-query-n/7818/1 "2024-09-11T13:56:55Z")

</div>

I have defined my directives.graphql and have below code

```auto
scalar DateTime
scalar JSON
scalar FieldSet

type _Service {
  sdl: String!
}

extend type Query {
  _service: _Service!
}

directive @key(
  fields: FieldSet!
  resolvable: Boolean = true
) repeatable on OBJECT | INTERFACE

```

and Users.graphql has below type defined

```auto
type SocialMedia @key(fields: "id") {
  id: ID
  name: String
}

```

and when i start the server it gives me the error defined in title

my apollo config is

```auto
import { ApolloError, ValidationError } from 'apollo-server-errors';
import { GraphQLError } from 'graphql';
import logger from 'logger';
import typeDefs from '../src/graphql/schema';
import RESOLVERS from '../src/resolvers';
import { buildSubgraphSchema } from '@apollo/subgraph';

export default {
  schema: buildSubgraphSchema([{ typeDefs: typeDefs, resolvers: RESOLVERS }]),
  formatError: (error) => {
    if (
      error.originalError instanceof ApolloError ||
      error instanceof ValidationError
    ) {
      return error;
    }

    logger.error(error);

    return new GraphQLError(error);
  },
  context: ({ req }) => {
    return {
      userId: req.headers?.['x-user-id'],
      whiteLabelEmail: req.headers?.['x-white-label-email'],
      ip: req.headers?.['x-ip'],
    };
  },
};

```

Dependencies being utilised

```auto
  "@apollo/server": "^4.11.0",
   "@apollo/subgraph": "^2.9.0"

```
