If there is conflict between modules, prefers right module and overrides left module's definitions and resolvers .
type Character {
id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
}
type Human @inherits(type: "Character") {
totalCredits: Int
}
type Droid @inherits(type: "Character") {
primaryFunction: String
}
type Character {
id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
}
type Human {
id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
totalCredits: Int
}
type Droid {
id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
primaryFunction: String
}
type Character {
id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
}
type Human @inherits(type: "Character") {
id: Int!
totalCredits: String
}
type Character {
id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
}
type Human {
id: Int!
name: String!
friends: [Character]
appearsIn: [Episode]!
totalCredits: String
}
...
import * as moduleA from '/your/moduleA';
import * as moduleB from '/your/moduleB';
const schema = buildSchema([moduleA, moduleB]);
const server = new ApolloServer({
schema,
});
...
import { buildSchema } from 'graphql-utils';
import * as moduleA from '/your/moduleA';
import * as moduleB from '/your/moduleB';
const schema = buildSchema([moduleA, moduleB]);
const server = new ApolloServer({
schema: buildSubgraphSchema(schema),
});
const resolvers = {
Query: {
getUser: () => {
return {
id: 1,
name: 'The',
}
},
},
User: {
name: (parent) => {
return parent.name;
}
}
};
const resolvers = {
Query: {
getUser: extend((oldResolver, parent) => {
const result = oldResolver(parent);
return {
...result,
name: result.name + ' White';
}
}),
},
User: {
name: (parent) => {
return 'Gandalf ' + parent.name;
}
}
};
{
"getUser": {
"id": "1"
"name": "Gandalf The White",
}
}