Skip to content

Instantly share code, notes, and snippets.

@iliran11
Last active May 4, 2020 05:07
Show Gist options
  • Save iliran11/2fd9085e523fc258c69d91e93d354921 to your computer and use it in GitHub Desktop.
Save iliran11/2fd9085e523fc258c69d91e93d354921 to your computer and use it in GitHub Desktop.
Wire the directive into Apollo server.
// Importing the directive
const intlDirective = require("./intlDirective");
const typeDefs = gql`
directive @intl on FIELD_DEFINITION
type Query {
// declaring we want to use the directive
# Makring "greeting" field for internationalization.
greeting: String @intl
id: Int
}
`;
// ....
const server = new ApolloServer({
typeDefs,
resolvers,
context: async ({ req }) => {
// .....
},
// Wire our directive into the config object.
schemaDirectives: {
intl: intlDirective,
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment