Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
language: node_js

node_js:
- "8"
- "10"

addons:
postgresql: "9.4"
apt:
packages:
- postgresql-server-dev-9.4

env:
TEST_DATABASE_URL: postgres://localhost:5432/travis
PGVERSION: 9.4

cache: yarn

install:
- yarn

before_script:
- psql -c "ALTER USER travis WITH PASSWORD 'travis';"
- sudo service postgresql restart

script:
- scripts/test

matrix:
include:
- addons:
apt:
packages:
- postgresql-10
- postgresql-client-10
- postgresql-server-dev-10
postgresql: 10
env:
- PGPORT=5433
- TEST_DATABASE_URL=postgres://travis:travis@localhost:5433/travis
- PGVERSION=10
sudo: false
dist: trusty
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"configurations": [
{
"type": "node",
"request": "launch",
"name": "debug tests",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand"],
"envFile": "${workspaceFolder}/.env"
}
]
}
36 changes: 36 additions & 0 deletions __tests__/__fixtures__/federatedServiceExtendingUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { gql } from "graphile-utils";

import { ApolloServer } from "apollo-server";
import { buildFederatedSchema } from "@apollo/federation";

const typeDefs = gql`
type Query {
empty: ID
}

extend type User @key(fields: "nodeId") {
nodeId: ID! @external
firstName: String! @external
lastName: String! @external
fullName: String! @requires(fields: "firstName lastName")
}
`;

const resolvers = {
User: {
fullName({ firstName, lastName }: { firstName: string; lastName: string }) {
return `${firstName} ${lastName}`;
},
},
};

export function startFederatedServiceExtendingUser() {
return new ApolloServer({
schema: buildFederatedSchema([
{
typeDefs,
resolvers,
},
]),
});
}
247 changes: 247 additions & 0 deletions __tests__/__snapshots__/integration.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`federated service: federated schema 1`] = `
type Email implements Node {
"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
"""
nodeId: ID!
id: Int!
email: String!

"""Reads and enables pagination through a set of \`UsersEmail\`."""
usersEmailsByEmailIdList(
"""Only read the first \`n\` values of the set."""
first: Int

"""Skip the first \`n\` values."""
offset: Int

"""The method to use when ordering \`UsersEmail\`."""
orderBy: [UsersEmailsOrderBy!]

"""
A condition to be used in determining which values should be returned by the collection.
"""
condition: UsersEmailCondition
): [UsersEmail!]!
}

"""
A condition to be used against \`Email\` object types. All fields are tested for equality and combined with a logical ‘and.’
"""
input EmailCondition {
"""Checks for equality with the object’s \`id\` field."""
id: Int

"""Checks for equality with the object’s \`email\` field."""
email: String
}

"""Methods to use when ordering \`Email\`."""
enum EmailsOrderBy {
NATURAL
ID_ASC
ID_DESC
EMAIL_ASC
EMAIL_DESC
PRIMARY_KEY_ASC
PRIMARY_KEY_DESC
}

"""An object with a globally unique \`ID\`."""
interface Node {
"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
"""
nodeId: ID!
}

type Query {
"""
Exposes the root query type nested one level down. This is helpful for Relay 1
which can only query top level fields if they are in a particular form.
"""
query: Query!

"""
The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
"""
nodeId: ID!

"""Fetches an object given its globally unique \`ID\`."""
node(
"""The globally unique \`ID\`."""
nodeId: ID!
): Node

"""Reads a set of \`Email\`."""
allEmailsList(
"""Only read the first \`n\` values of the set."""
first: Int

"""Skip the first \`n\` values."""
offset: Int

"""The method to use when ordering \`Email\`."""
orderBy: [EmailsOrderBy!]

"""
A condition to be used in determining which values should be returned by the collection.
"""
condition: EmailCondition
): [Email!]

"""Reads a set of \`User\`."""
allUsersList(
"""Only read the first \`n\` values of the set."""
first: Int

"""Skip the first \`n\` values."""
offset: Int

"""The method to use when ordering \`User\`."""
orderBy: [UsersOrderBy!]

"""
A condition to be used in determining which values should be returned by the collection.
"""
condition: UserCondition
): [User!]

"""Reads a set of \`UsersEmail\`."""
allUsersEmailsList(
"""Only read the first \`n\` values of the set."""
first: Int

"""Skip the first \`n\` values."""
offset: Int

"""The method to use when ordering \`UsersEmail\`."""
orderBy: [UsersEmailsOrderBy!]

"""
A condition to be used in determining which values should be returned by the collection.
"""
condition: UsersEmailCondition
): [UsersEmail!]
emailById(id: Int!): Email
userById(id: Int!): User
usersEmailByUserIdAndEmailId(userId: Int!, emailId: Int!): UsersEmail

"""Reads a single \`Email\` using its globally unique \`ID\`."""
email(
"""The globally unique \`ID\` to be used in selecting a single \`Email\`."""
nodeId: ID!
): Email

"""Reads a single \`User\` using its globally unique \`ID\`."""
user(
"""The globally unique \`ID\` to be used in selecting a single \`User\`."""
nodeId: ID!
): User

"""Reads a single \`UsersEmail\` using its globally unique \`ID\`."""
usersEmail(
"""
The globally unique \`ID\` to be used in selecting a single \`UsersEmail\`.
"""
nodeId: ID!
): UsersEmail
empty: ID
}

type User implements Node {
"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
"""
nodeId: ID!
id: Int!
firstName: String!
lastName: String!

"""Reads and enables pagination through a set of \`UsersEmail\`."""
usersEmailsByUserIdList(
"""Only read the first \`n\` values of the set."""
first: Int

"""Skip the first \`n\` values."""
offset: Int

"""The method to use when ordering \`UsersEmail\`."""
orderBy: [UsersEmailsOrderBy!]

"""
A condition to be used in determining which values should be returned by the collection.
"""
condition: UsersEmailCondition
): [UsersEmail!]!
fullName: String!
}

"""
A condition to be used against \`User\` object types. All fields are tested for equality and combined with a logical ‘and.’
"""
input UserCondition {
"""Checks for equality with the object’s \`id\` field."""
id: Int

"""Checks for equality with the object’s \`firstName\` field."""
firstName: String

"""Checks for equality with the object’s \`lastName\` field."""
lastName: String
}

type UsersEmail implements Node {
"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
"""
nodeId: ID!
userId: Int!
emailId: Int!

"""Reads a single \`User\` that is related to this \`UsersEmail\`."""
userByUserId: User

"""Reads a single \`Email\` that is related to this \`UsersEmail\`."""
emailByEmailId: Email
}

"""
A condition to be used against \`UsersEmail\` object types. All fields are tested
for equality and combined with a logical ‘and.’
"""
input UsersEmailCondition {
"""Checks for equality with the object’s \`userId\` field."""
userId: Int

"""Checks for equality with the object’s \`emailId\` field."""
emailId: Int
}

"""Methods to use when ordering \`UsersEmail\`."""
enum UsersEmailsOrderBy {
NATURAL
USER_ID_ASC
USER_ID_DESC
EMAIL_ID_ASC
EMAIL_ID_DESC
PRIMARY_KEY_ASC
PRIMARY_KEY_DESC
}

"""Methods to use when ordering \`User\`."""
enum UsersOrderBy {
NATURAL
ID_ASC
ID_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
LAST_NAME_ASC
LAST_NAME_DESC
PRIMARY_KEY_ASC
PRIMARY_KEY_DESC
}

`;
Loading