Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still work, when don't use import? #44

Open
thearabbit opened this issue Aug 21, 2019 · 2 comments
Open

Still work, when don't use import? #44

thearabbit opened this issue Aug 21, 2019 · 2 comments

Comments

@thearabbit
Copy link

thearabbit commented Aug 21, 2019

I have 2 schema Assignee and Task

type Assignee {
  _id: String!
  name: String!
  gender: String!
}
#import "../assignees/schema.graphql"

type Task {
  _id: String!
  title: String!
  description: String
  assignee: Assignee
}

It work fine.
But still work, if I remove #import ....?
Could explain me?
(I use merge-graphql-schemas to merge)

@jamiter
Copy link
Contributor

jamiter commented Aug 22, 2019

Hi. Maybe it was cached somewhere. I can't say without knowing you're complete setup.

@thearabbit
Copy link
Author

thanks for your reply.

// Client
import { Meteor } from 'meteor/meteor'
import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { ApolloLink } from 'apollo-link'
import { HttpLink } from 'apollo-link-http'
import { MeteorAccountsLink } from 'meteor/apollo'

export default new ApolloClient({
  link: ApolloLink.from([
    new MeteorAccountsLink(),
    new HttpLink({
      uri: Meteor.absoluteUrl('graphql'),
    }),
  ]),
  cache: new InMemoryCache(),
  defaultOptions: {
    watchQuery: {
      fetchPolicy: 'no-cache',
      errorPolicy: 'ignore',
    },
    query: {
      fetchPolicy: 'no-cache',
      errorPolicy: 'all',
    },
  },
})
---------------
// Server
import { ApolloServer, AuthenticationError } from 'apollo-server-express'
import { WebApp } from 'meteor/webapp'
import { getUser } from 'meteor/apollo'
import { mergeTypes, mergeResolvers } from 'merge-graphql-schemas'

// Get schemas
import { typeDefs, resolvers } from './apollo-schema'

// Create apollo server
const server = new ApolloServer({
  typeDefs: mergeTypes(typeDefs, { all: true }),
  resolvers: mergeResolvers(resolvers),
  context: async ({ req }) => {
    const user = await getUser(req.headers.authorization)
    // In the browser console, enter
    // localStorage.getItem('Meteor.loginToken')
    if (user) return { user }

    console.log('AuthenticationError: You must be logged in')
    throw new AuthenticationError('You must be logged in')
  },
})

server.applyMiddleware({
  app: WebApp.connectHandlers,
  path: '/graphql',
})

WebApp.connectHandlers.use('/graphql', (req, res) => {
  if (req.method === 'GET') {
    res.end()
  }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants