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
const express = require("express"); | |
const { ApolloServer, gql } = require("apollo-server-express"); | |
const cookieParser = require("cookie-parser"); | |
const intlDirective = require("./intlDirective"); | |
// init i18next module. | |
require("./i18next"); | |
... | |
... |
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 | |
} |
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
const { SchemaDirectiveVisitor } = require("graphql-tools"); | |
const { defaultFieldResolver } = require("graphql"); | |
const i18next = require("i18next"); | |
class IntlDirective extends SchemaDirectiveVisitor { | |
visitFieldDefinition(field) { | |
const { resolve = defaultFieldResolver } = field; | |
field.resolve = async (...args) => { | |
const context = args[2]; | |
const info = args[3]; | |
const value = await resolve.apply(this, args); |
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
const server = new ApolloServer({ | |
typeDefs, | |
resolvers, | |
context: async ({ req }) => { | |
// now we have the user requeted language | |
const t = await i18Next("es"); | |
return { t }; | |
}, | |
}); |
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
const i18next = require("i18next"); | |
i18next.init({ | |
lng, | |
resources: { | |
en: { | |
translation: { | |
greeting_key: "hello", | |
}, | |
}, | |
es: { |
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
const server = new ApolloServer({ | |
typeDefs, | |
resolvers, | |
context: async ({ req }) => { | |
// now we have the user requeted language | |
const lng = req.cookies.lng; | |
return { lng }; | |
}, | |
}); |
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
const express = require("express"); | |
const { ApolloServer, gql } = require("apollo-server-express"); | |
const cookieParser = require("cookie-parser"); | |
const bodyParser = require("body-parser"); | |
// Construct a schema, using GraphQL schema language | |
const typeDefs = gql` | |
type Query { | |
greeting: String | |
id: Int |
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
const typeDefs = gql` | |
directive @intl on FIELD_DEFINITION | |
type Query { | |
# Makring "greeting" field for internationalization. | |
greeting: String @intl | |
id: Int | |
} | |
`; |
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
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve"> | |
<circle style="fill: #32cbd6;" cx="256" cy="267" r="245"/> | |
<path style="fill:#D9EAFC;" d="M61.914,416.511C106.715,474.582,176.982,512,256,512c47.739,0,92.279-13.668,129.948-37.284V134.345 H61.914V416.511z"/> | |
<path style="fill:#C3DDF4;" d="M81.756,134.345H61.914v282.166c6.144,7.964,12.783,15.524,19.842,22.668V134.345z"/> | |
<rect x="61.914" y="35.902" style="fill:#02AF8E;" width="324.03" height="99.44"/> | |
<rect x="61.914" y="35.902" style="fill:#0F9390;" width="19.842" height="99.44"/> | |
<path style="fill:#1A2B63;" d="M376.391,0H71.472c-5.257,0-9.558,4.301-9.558,9.558v27.344h324.034V9.558 C385.948,4.301,381.647,0,376.391,0z"/> | |
<path style="fill:#52BBEF;" d="M347.98,295.832c0,1.965-1.608,3.573-3.572,3.573H201.505c-1.965,0-3.572-1.608-3.572-3.573v-95.744 c0-1.965,1.607-3.573,3.572-3.573h142.903c1.965,0,3.57 |
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
document.querySelectorAll('.match-results-card').forEach((node)=>{ | |
const hrefAttr = node.getAttribute('href'); | |
const window = window.open(hrefAttr); | |
console.log(window) | |
}) |
NewerOlder