1

I am currently using Apollo-server as my GraphQL server of choice and anytime I try to run tests I get the error indicated in the title. However, my server implementation works as expected.

import 'cross-fetch/polyfill';
import ApolloClient, { gql } from 'apollo-boost';

const client = new ApolloClient({
  uri: 'http://localhost:4000/',
});

const USER = {
  invalidPassWord : {
    name: 'Gbolahan Olagunju',
    password: 'dafe',
    email: '[email protected]'
  },
  validCredentials: {
    name: 'Gbolahan Olagunju',
    password: 'dafeMania',
    email: '[email protected]'
  },
  usedEmail: {
    name: 'Gbolahan Olagunju',
    password: 'dafeMania',
    email: '[email protected]'
  }
};

describe('Tests the createUser Mutation', () => {
  test('should not signup a user with a password less than 8 characters', () => {
    const createUser = gql`
    mutation {
      createUser(data: USER.invalidPassWord){
        token
        user {
          name
          password
          email
          id
        }
      }
    }
    `
    
    client.mutate({
      mutation: createUser
    }).then(res => console.log(res));
  })
})

1
  • Is there any error message? Commented Nov 18, 2019 at 12:21

2 Answers 2

2

There is a problem with the document used in your test. USER.invalidPassWord is not valid GraphQL syntax. Presumably you meant to use a template literal there to reference the USER variable defined earlier.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks this seems to be the issue an invalid GraphQL syntax
0

Doing the GrapQL tutorial at

https://www.howtographql.com/react-apollo/1-getting-started/

gives the same error.

I have razed the "same" issue at their site, though is the problem another in my case.

https://github.com/howtographql/howtographql/issues/1047

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.