API.swift file not update : Apollo GraphQL iOS

Viewed 2219

I am using GraphQL API with iOS project.my .graphql file is,

mutation SigninQuery($email: String! , $password: String!) {
    signin(email: $email, password: $password) {
        result {
            token
            firstName
            lastName
            profileImage
        }
    }
}

and my files are located in the following order,

Project

  • ->appDelegate
  • ->info.plist
  • ->schema.json
  • -->Graphql[Folder]

  • ->API.swift

  • ->ApiFile.graphql

My API.swift file still exist only with header

import Apollo

. Anyone can you please help me to findout the solution

1 Answers

If you correct initialized the apollo client, then you won't have such a problem. I installed Apollo using Swift packages. I did following steps:

  1. Hierarchy

enter image description here

  1. Script to generate API.swift (pay attention on folder to generate and name of schema. In my case, folder is GraphQL and name is tetsTet):
    DERIVED_DATA_CANDIDATE="${BUILD_ROOT}"

     while ! [ -d "${DERIVED_DATA_CANDIDATE}/SourcePackages" ]; do
       if [ "${DERIVED_DATA_CANDIDATE}" = / ]; then
         echo >&2 "error: Unable to locate SourcePackages directory from BUILD_ROOT: '${BUILD_ROOT}'"
        exit 1
       fi

  DERIVED_DATA_CANDIDATE="$(dirname "${DERIVED_DATA_CANDIDATE}")"
done

# Grab a reference to the directory where scripts are checked out
SCRIPT_PATH="${DERIVED_DATA_CANDIDATE}/SourcePackages/checkouts/apollo-ios/scripts"

if [ -z "${SCRIPT_PATH}" ]; then
    echo >&2 "error: Couldn't find the CLI script in your checked out SPM packages; make sure to add the framework to your project."
    exit 1
fi

cd "${SRCROOT}/${TARGET_NAME}/GraphQL"
"${SCRIPT_PATH}"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile="tetsTets.json" API.swift
  1. Drag the generated API.swift file to your folder

uncheck the "Copy Files If Needed" checkbox

Related