EQuimper / twitter-clone-with-graphql-reactnative

164 stars 71 forks source link

react-apollo / syntax error #47

Closed gHashTag closed 6 years ago

gHashTag commented 6 years ago

on the react-apollo question. How to resolve a syntax error? on the server I cause and all works smile 2017-11-26 1 39 08

my mutation

import { gql } from 'react-apollo'

export default gql`
mutation {
  masterCreate($studioID: String!, $name: String!, $profession: String! $img: String!  $imgSmall: String!, $info: String!) {
    masterCreate(record: { 
    studioID: $studioID 
    name: $name 
    profession: $profession 
    img: $img 
    imgSmall: $imgSmall 
    info: $info 
    }
    ) {
    record {
      _id
      name
      profession
      img
      imgSmall
      info
      studio {
        name
      }
    }
  } 
}
`

> ExceptionsManager.js:65 Syntax Error GraphQL request (3:16) Expected Name, found $
> 
> 2: mutation {
> 3:   masterCreate($studioID: String!, $name: String!, $profession: String! $img: String!  $imgSmall: String!, $info: String!) {
>                   ^
> 4:     masterCreate(record: {
ryanyogan commented 6 years ago

You are missing a comma after $img: String!

On Sat, Nov 25, 2017 at 2:49 PM, Dimka Vasilyev notifications@github.com wrote: on the react-apollo question. How to resolve a syntax error? on the server I cause and all works smile [https://user-images.githubusercontent.com/6774813/33235577-c869d776-d24b-11e7-8d76-8a5f55fca528.png]

my mutation

import { gql } from'react-apollo'exportdefaultgqlmutation { masterCreate($studioID: String!, $name: String!, $profession: String! $img: String! $imgSmall: String!, $info: String!) { masterCreate(record: { studioID: $studioID name: $name profession: $profession img: $img imgSmall: $imgSmall info: $info } ) { record { _id name profession img imgSmall info studio { name } } } }>ExceptionsManager.js:65 Syntax Error GraphQL request (3:16) Expected Name, found $

2: mutation { 3:masterCreate($studioID:String!, $name:String!, $profession:String!$img:String!$imgSmall:String!, $info:String!) { ^>4:masterCreate(record: {

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub [https://github.com/EQuimper/twitter-clone-with-graphql-reactnative/issues/47] , or mute the thread [https://github.com/notifications/unsubscribe-auth/AACifHTwuuD13RT604qcLN3oICo7ktn8ks5s6JmXgaJpZM4Qqlca] .

ryanyogan commented 6 years ago

And after $profession: String! Everything else looks fine, you should be good to go.

On Sat, Nov 25, 2017 at 3:26 PM, Ryan Yogan ryanyogan@gmail.com wrote: You are missing a comma after $img: String!

On Sat, Nov 25, 2017 at 2:49 PM, Dimka Vasilyev notifications@github.com wrote: on the react-apollo question. How to resolve a syntax error? on the server I cause and all works smile [https://user-images.githubusercontent.com/6774813/33235577-c869d776-d24b-11e7-8d76-8a5f55fca528.png]

my mutation

import { gql } from'react-apollo'exportdefaultgqlmutation { masterCreate($studioID: String!, $name: String!, $profession: String! $img: String! $imgSmall: String!, $info: String!) { masterCreate(record: { studioID: $studioID name: $name profession: $profession img: $img imgSmall: $imgSmall info: $info } ) { record { _id name profession img imgSmall info studio { name } } } }>ExceptionsManager.js:65 Syntax Error GraphQL request (3:16) Expected Name, found $

2: mutation { 3:masterCreate($studioID:String!, $name:String!, $profession:String!$img:String!$imgSmall:String!, $info:String!) { ^>4:masterCreate(record: {

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub [https://github.com/EQuimper/twitter-clone-with-graphql-reactnative/issues/47] , or mute the thread [https://github.com/notifications/unsubscribe-auth/AACifHTwuuD13RT604qcLN3oICo7ktn8ks5s6JmXgaJpZM4Qqlca] .

gHashTag commented 6 years ago

@ryanyogan

thanks, corrected commas) but somewhere else I am afraid. what's wrong?

import { gql } from 'react-apollo'

export default gql`
mutation {
  masterCreate($studioID: String!, $name: String!, $profession: String!, $img: String!,  $imgSmall: String!, $info: String!) {
    masterCreate(record: { 
    studioID: $studioID 
    name: $name 
    profession: $profession 
    img: $img 
    imgSmall: $imgSmall 
    info: $info 
    }
    ) {
    record {
      _id
      name
      profession
      img
      imgSmall
      info
      studio {
        name
      }
    }
  } 
}
`
Unhandled JS Exception: Syntax Error GraphQL request (3:16) Expected Name, found $

> 2: mutation {
> 3:   masterCreate($studioID: String!, $name: String!, $profession: String!, $img: String!,  $imgSmall: String!, $info: String!) {
>                   ^
> 4:     masterCreate(record: {
gHashTag commented 6 years ago

on the server I use this library and created there a similar question, with little progress https://github.com/nodkz/graphql-compose-mongoose/issues/79

gHashTag commented 6 years ago

No errors, it works, thanks!

import { gql } from 'react-apollo'

export default gql`
mutation masterCreate($record: CreateOneMasterInput) {
    masterCreate(record: $record
    ) {
    record {
      _id
      name
      profession
      img
      imgSmall
      info
      studio {
        name
      }
    }
  }
  }
`