Last active
May 4, 2020 05:07
-
-
Save iliran11/2fd9085e523fc258c69d91e93d354921 to your computer and use it in GitHub Desktop.
Wire the directive into Apollo server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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